By this point in the story, Huck has figured out that the king and duke are scoundrels and that he and Jim needed to get away from them as quickly as possible. However, the news that the king had sold Jim forces Huck to focus on a much bigger problem with many more complicating factors.
Huck's upbringing told him that slavery was the natural state for "niggers" and that the biggest problem was that Jim was being sold down the river, separated from his family. Huck considers notifying Tom Sawyer about Jim's whereabouts so Tom could notify Miss Watson and she could come and buy him back, but is mortified to think of what such a course of action would do to his reputation.
It would get all around, that Huck Finn helped a nigger to get his freedom; and if I was to ever see anybody from that town again, I'd be ready to get down and lick his boots for shame.
Huck decides to pray for forgiveness for helping a runaway slave but finds he can't do so because, deep down, he doesn't regret helping Jim and doesn't want to tell Miss Watson where he was. He writes Miss Watson a letter with the information and hopes this will release him from all the guilt and sin, but starts thinking - at first about his sin in helping Jim run away, and then about the trip he and Jim have been sharing down the Mississippi.
As hard as Huck tries, he can't find reason to condemn Jim to a return to slavery, either down the river or with Miss Watson.
somehow I couldn't seem to strike no places to harden me against him, but only the other kind....I was a trembling, because I'd got to decide, forever, betweixt two things, and I knowed it....'All right, then, I'll go to hell'....And for a starter, I would go to wrk and steal Jim out of slavery again;
Huck's friendship with Jim and his repeated recognition of Jim's kindness and humanity (much to Huck's amazement) forces Huck to change his way of thinking and acting, determining to help Jim obtain his freedom at any personal cost.