One of the themes in Mark Twain's The Adventures of Huckleberry Finn, is "conscience." In this, Twain presents young Huck whose father is a no-good, abusive drunk. The women who have been trying to "civilize" him uphold the morals and social standards of the South, which they have tried to teach him—what most affects Huck the most about the social norms of the South, of course, is Jim's quest for freedom, and Huck's part in it.
Ironically, Huck believes that he is really bad—when he was simply traveling with Jim in his bid for freedom, Huck believes he was acting unethically because he knew that Jim was running away. Continuing to help Jim is another blot on his soul, as far as Huck is concerned. And as much as he likes Jim, he believes the only right thing to do is to turn him in to the law.
Huck goes ashore one day with just such an intent. However, when it comes right down to it, he just cannot give Jim up. Huck returns to the raft feeling really low—he's once again broken society's laws, so there must just be no hope for him. Since he cannot conform to the society of which he is a part, he expects he will have to live with his evil ways.
If these tests of conscience are not enough, when the Duke and the King turn Jim in, Huck must not only turn his back on society's dictates, but must take a stand about what he is going to do—if anything—regarding Jim's imprisonment. Huck cannot ignore his friend—he cannot leave him to his own resources—so he becomes involved in a plan to free Jim, believing that he is turning his back on what is right in God's sight and that he will burn in hell for it—and well, so be it. However, it is clear in this part of the novel that Huck is not listening to the voice that harps on what society demands, but on what his fondness for his friend is telling him.
Through Huck, Twain attacks that part of the conscience that unquestioningly adheres to society's laws and mores, even when they are wrong.
Huck begins the novel helping Jim, which he believes is wrong because society has said so, but literally doing what is morally right. He continues to chastise himself for the part he plays in maintaining Jim's freedom from slavery; even when he tries to do what he thinks is right by turning Jim in, he cannot do so. By the story's end, Huck even helps Jim escape (using a harebrained scheme Tom Sawyer hatches), which is a very serious crime at that time, in that place. However, Jim is more important to Huck than his fear of the law or getting hurt. In doing this, Huck gives himself up to his eventual trip to hell, for he will not turn his back on Jim, even though he believes he is "low down" for doing so. He decides to turn his back on society instead.
And the irony is that this backwoods, "uncivilized" boy has more compassion and humanity than all the civilized adults that surround him.