Having been raised in a state that accepted slavery as the proper relationship between whites and blacks, Huck's morals at the beginning of the book see no reason for concern about Miss Watson's ownership of Jim or the ways in which he and Tom treat Jim. He assumed it was perfectly normal to treat him as a piece of property, to play tricks on him for their own amusement, to expect him to do all the hard work.
As Huck and Jim travel down the river and share adventures, Huck comes to see things differently. He finds out that Jim has useful knowledge that makes their camping on the island more comfortable. He discovers that Jim has deep feelings for his family and grieves when he considers that he likely will never see them again. Huck finds himself recognizing all the kindnesses Jim does for him, the ways in which Jim takes care of him and considers him a friend.
Huck discovers he has come to think of Jim as a person, not a slave. He fights the realization, without success.
I was trying to make my mouth say I would do the right thing and the clean thing, and go and write to that nigger's owner and tell where he was; but deep down in me I knowed it was a lie-and He knowed it.
Huck finally concludes he can't betray Jim. "I would go to work and steal Jim out of slavery again." His morals can no longer accept the enslavement of his friend.