(Click the character infographic to download.)
Sorry to disappoint you, but these aren't a real Duke and King. Nope. They're conmen who team up to bilk the gullible people of more than one riverside town.
Of the two, the king is definitely the worst. In the first con the two men pull, the duke steals a measly nine bucks—not even enough for a pizza. The king, on the other hand, pretends to be a preacher in order to steal a whole $80.
Not too cool.
Okay, but other than being examples of What Not to Do, the duke and king have two important roles in the novel: (1) they're like a bizzaro-world version of Huck and Jim; and (2) they're a major part of Huck's maturation.
Let's look at bizzaro-world, first. When the duke and king first meet, they consider conning each other and then decide that they'd be better off teaming up:
Like as not we got to be together a blamed long time on this h-yer raft, Bilgewater, and so what's the use o' your bein' sour? It 'll only make things on-comfortable. It ain't my fault I warn't born a duke, it ain't your fault you warn't born a king—so what's the use to worry? Make the best o' things the way you find 'em, says I—that's my motto. This ain't no bad thing that we've struck here—plenty grub and an easy life—come, give us your hand, duke, and le's all be friends. (19.47)
So, first, we get the sense again that the duke has the high moral ground in the this pair; second, we learn that these guys aren't pairing up out of loyalty or friendship, but for "plenty grub and an easy life." In other words, we wouldn't bet on this team in The Amazing Race.
At first, Huck is having a grand old time. No rules, no sitting up straight, and definitely no Sunday School. Soon enough, he starts to wonder if maybe life on the lam isn't so great after all, especially when the king and duke start trying to cheat the pretty Mary Jane out of her inheritance.
And when the duke and king end up tarred and feathered, Huck realizes that he's probably going to better off staying on the right side of the law. And that's a lesson worthy of royalty.