Published in the early 1880's, Mark Twain was well known for his books The Adventures of Tom Sawyer, a sequel to the other known book, The Adventures of Huckleberry Finn. During this period of time, slavery has been abolished from the US, the 13th Ammendment stating "neither slavery nor involuntary servitude… shall exist within the United States, or any place subject to their jurisdiction.”
Mark Twains stories touched topics that weren't that appreciated back then, than they are now. His stories were about slavery and his view of it. Mark was anti-slavery, which outraged the people of that time, since slavery was big then. The protagonist in Huckleberry was also anti-slavery, which caused more controversy on the view of the story. I believe Mark wrote this to show that the colored and non colored are not different at all, only the color of their skin. He wrote this to show that they can work together and be united, to abolish the nonsense belief.