The king and the duke, as Huck quickly realises when they come to join him and Jim on the raft, are a shady pair of con-men. The duke is considerably younger and evidently the more educated of the two, while the king is outwardly more seedy and vulgar, and drunk, but they are both devious, mean-spirited and desperate for money. They are a couple of low-down rogues, yet they parade themselves as being of high social standing, claiming to be of royal and aristocratic descent. In this way Twain makes fun of people's obsession with social class and grandeur. But the satire also works the other way; Huck observes cynically that they are just as bad as real kings and dukes.
Mark Twain, who lived through the Civil War and was a riverboat captain himself on the Mississippi, may have been satirizing with the characters of the king and the duke the carpetbaggers and flim-flam men who came from the North in order to exploit vulnerable Southerners. Many of these men were unconscionable and took advantage any financial opportunity that offered itself. Often they tricked women left vulnerable because their male relatives were killed in the war.
In Chapters XXIV-XXV, these two "rapscallions" learn of a large inheritance that is coming to the relatives of Peter Wilks; so, the king assumes the role of the English preacher Harvey Wilks in order to scam money from the Wilks family. The duke pretends to be the mute brother William. After committing their crime, the greedy king wants to return in order to take more:
"What! And not sell out the rest of the property?...We shan't rob 'em of nothing at all jest this money.
Further, after they run out of cash in Chapter XXXI, they steal Jim, and they sale him for $40.00.