The underlying moral dilemma in The Adventures of Huckleberry Finn is the question of how to relate to and treat black people.
Varied characters within the story have their own viewpoints regarding the slaves in their midst and act accordingly in their dealings with them. Huck's opinion evolves through the course of events, changing from:
He was thinking about his wife and his children, away up yonder, and he was low and homesick; because he hadn't ever been away from home before in his life; and I do believe he cared just as much for his people as white folks does for their'n. It don't seem natural, but I reckon it's so.
somehow I couldn't seem to strike no places to harden me against him, but only the other kind. I'd see him standing my watch on top of his'n, stead of calling me, so I could go on sleeping; and see him how glad he was when I come back out of the fog; ... and at last I struck the time I saved him by telling the men we had small-pox aboard, and he was so grateful, and said I was the best friend old Jim ever had in the word, and the only one he's got now
So Huck, who would be looked down upon by many of the characters in the story because he was unschooled and poorly clothed and had no family or refinements of social upbringing, determined that he would go to hell if that was what happened but he would not allow his friend to be sold back into slavery.