There's more than one piece by Twain to try answering that question, but this is as good a place as any.
How Pudd'nhead Wilson was birthed is arguably, to writers at least, as interesting as the story itself. It was originally written as farce, but the unexpected calls of the emerging plot for logic and continuity pulled Twain this way and that, regardless of what he thought about it all. Along the way, certain characters turned out to be not as important as Twain had surmised, and other characters became a good deal more important. In the end, Pudd’nhead emerged as the unlikely hero of what, to Twain’s surprise, turned out to be a tragedy.
The fact that it is a tragedy was highlighted by some of Twain’s publishers, whom, perhaps for marketing reasons, called it The Tragedy of Pudd’nhead Wilson, something Twain wouldn’t have done because the tragedy doesn’t belong to Pudd’nhead. Other publishers just called it Pudd’nhead Wilson, perhaps to save on typeface, or tried out Pudd’nhead Wilson and Those Extraordinary Twins, presumably to up the intrigue and extract dollars from pockets.
Either way, it’s still in publication, like most of Samuel Clemens’ work, and for good reason – he’s an insightful and honest writer.
Clemens is sometimes accused of holding to the racism of his time regarding slavery and of ‘negroes’ being from a ‘lower order’ of humanity. I understand why people might think this. Huck Finn does feature a ‘challenging’ portrayal of ‘niggers’, one in particular, as simple. On the other hand, Pudd’nhead Wilson creates the most detailed portrayal of Roxana, a free African-American of the servant class, and her illegitimate son, whom she raises up only to… Well, I won’t include spoilers but all does not go well. The point is that characters are served as characters, and not as ciphers for a racist mindset or ideology.
Clemens relishes great care on Roxana’s dialogue. Some might call this racist charicature, but I rather think Clemens was just a good observer, faithful listener and transcriber of the patois. Also, without giving away the tale, one character, raised a certain way, is unable to change his speech or behaviour despite his race being revealed to be other than what he thought it was – in other words, Clemens makes nurture, rather than nature, the main arbiter of human character.
That said, Clemens could’ve gotten away with any amount of outright racism back then, whereas portrayal of ‘colour’ is a fraught area for contemporary writers. As an Anglo-Australian, I could write a portrayal of an Irishman without censure, but I would, arguably, come under critical scrutiny writing a person of colour. I can live with that - it’s probably a good thing, as my white culture continues to crawl out of the post-colonial era, racist as ever.
As for the story of Pudd'nhead, it suited being made into a play, and was. The play probably had some success - it has an unlikely and engaging hero, a dastardly villain, a vile murder and a few plot twists. It also discreetly challenges the racist stereotypes of ‘negroes’ as inferior, and highlights the cruelty and injustice of slavery via the threat of ‘being sold down the river’. This sword hangs over every ‘happy’ slave should they lose favour with their ‘owners’. And centre-stage, much more than Wilson himself, Roxana’s agony to do right, her mistakes, her brave fight to thwart injustice and make amends is played out.
Roxana’s a complex character – clever but foolish, just but conniving, loving but aggressive, fearful but brave. The villain is a wastrel good-for-nothing, and the plain (white) folk of the town are alternately generous and judgemental.
The chapter-headings include bon mots, ostensibly from one of Pudd’nhead’s hobbies – words of wisdom to be included on calendars. These are, I suspect, the only remnants of the farce this tale was intended to be, and are clearly Clemens inserting his acid wit to signal the story ahead.
So, Pudd’nhead Wilson is still a good read, has compassionate and philosophical depths, and an honesty that might help ease any accusations of racism put to a Southern gentleman-writer living in a slave culture.
Whatever you think of Mark Twain, he was no fool, and, for this reason alone, I don’t think he was capable of believing slavery could ever be, in any way, right.