Essentially, Huckleberry Finn is the story of one boy's journey through growing up and maturing through his experiences on the river. Although, while making this passage into manhood, Twain shows that Huck is a divided boy in his way to free Jim. Throughout the novel Twain shows that Huck is having a mental struggle as to whether he should turn in Jim as a runaway slave or lead him to his freedom, which gives the novel a sense of the struggle between morality and what is right to the laws.
The decision as to turn in Jim or not as a slave is tough for Huck because his mind is telling him what society has been telling him his whole life. Such pertinent and blatin evidence of this fight against conforming to what society says is seen when Huck constantly hears about rewards for a runaway slave. Even his own morality comes into play when he feels that he is doing wrong to Miss Watson when she never did anything bad to Huck. But what Huck constantly comes to realize is that he is doing a morally righteous thing because Jim is a human being, not something that can be bought or paid for. He also has to fight his own consciousness for reality when the two men that Huck needs help from ask if there is a slave on his raft because they have been searching for one. Huck could easily admit this to follow the "laws" but Huck sticks to his morals. This adds to the story as a whole by showing how morals are what must be followed, because the laws may be unjust to humanity.
Twain's purpose in creating this struggle pertaining to Huck's mental state is to sow in the story that people should not conform but do what is right for the sake of others. In this struggle Twain is showing the reader that by conforming to society, as Huck directly opposed, then we could become trapped by the immorality society and the "laws" may show, in this case the topic of slavery. Huck's mental struggle can be expounded to portray the struggle of the people of this time as to whether slavery is moral or not.