Why does Huck tries to help the Duke and King when he finds out the townspeople know about them?
The reason that Huck tries to help the "Duke" and the "King" is because he feels sorry for them as human beings. He does not want anything truly bad to happen to them even though he knows that they deserve it. This helps us see just how strong of a conscience Huck has and how he hates seeing people hurt.
Huck knows that the two con men deserve to be punished. But even so, he does not like to see them get hurt. He says
Well, it made me sick to see it; and I was sorry for them poor pitiful rascals, it seemed like I couldn't ever feel any hardness against them any more in the world. It was a dreadful thing to see. Human beings can be awful cruel to one another.
Huck has seen cruelty done to a lot of people. He has seen slaves treated cruelly and he has himself been abused by his father. Because of this he is very sensitive to the ways that other people feel and he does not like to see them hurt.