The "King" and the "Duke" played a huge role in the latter part of the book. They set up Jim being captured as a runaway slave, and triggered the entire convoluted "rescue mission" that takes up so much of the ending part of the book.
Why do we find confidence men so fascinating? And why do they keep being around and keep being so successful? The words Madoff, Nigerian and Phishing should trigger some images in your mind!
We're all secretly enamored with tricksters, confidence men and rogues. The movie The Sting won oodles of Academy Awards, and we all rooted for the scammers to win!
Huck both admired and disliked the King and the Duke for their actions. He was responsible for their eventual downfall. But, Huck lives his whole live like a series of tiny little scams. Huck seems incapable of telling the truth about anything, and will come up with a whopper or an alias before he even has time to think.
If we look at Huck Finn (the book) as a huge cautionary tale about scammers of one sort or another, what did Huck (or you?) learn by the end?