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.