Why does Huck risk punishment by helping Jim escape? What do Huck’s actions reveal about his character?
I agree with the first answer, but I would point out that Huck has already helped Jim escape long before he meets the King and the Duke. Therefore, he cannot really be basing his decision on their characters. After all, he could have turned Jim in way back on Jackson's Island.
To me, Huck just feels that somehow slavery is wrong. He does not like feeling that way, but somehow he does. In fact, he feels very bad about helping Jim escape.
What this shows is the central tension in Huck. He feels pressured to act in the ways that society expects, but he hates those rules. He wants to live by his own code.
So this is why Huck acts as he does. He is interested in living by his own code even though he feels he ought to obey what society says.
Jim may be a slave, but Huck also considers him a friend, a decent person, and an extended part of his family in Mark Twain's novel, The Adventures of Huckleberry Finn. Huck also realizes that Jim is a far better man than either of their unwanted compatriots, the Duke and the King. Huck realizes that once the pair of scoundrels sells Jim, then Jim will probably have a much tougher life than he has with Miss Watson. By risking arrest for helping an escaped slave to further elude authorities, Huck shows his true nature: A down-to-earth person who disdains civilized society, likes to live life on his own terms and who believes others should as well.