According to the Encyclopedia Britannica, in the novel "The Adventures of Huckleberry Finn" by Mark Twain, Huck wants to save the black slave Jim Turner because, despite the ubiquitous racial prejudices of the era, Huck has come to love and respect Jim. During the course of his adventures with Jim, Huck's good nature moves him to regard Jim as a friend.
A teacher's guide to "The Adventures of Huckleberry Finn" on the PBS website points out that the author Mark Twain had been raised, as Huck in the story, to believe that slavery was morally right. However, by the time he wrote the novel, he had come to realize that it was a great evil and actively opposed it not only in his writings, but also in his contributions towards education for black people.
According to the PBS article, the innocence of Huck and his childlike acceptance of the righteousness of the institution of slavery as he was taught contrasts with his ultimate decision to save Jim, no matter what the cost. As he has been told that the Bible justifies slavery, he is even willing to endure eternal damnation in order to see Jim free. Today, "The Adventures of Huckleberry Finn" is criticized for its depiction of the slave Jim Turner, but when it was first published, its sympathetic characterization of Jim aroused great controversy and debate on the issues of prejudice and racism.