Authors frequently use characters in their novels to express their personal thoughts or opinions.
Consider author Mark Twain and his main character in The Adventures of Huckleberry Finn. At the outset of the story, Huck perceived Jim and other slaves in the same way that most people in did at that time in that area - blacks were slaves because that was the only role they could acceptably fulfill in society. Huck appreciated Jim's company when they were on the river and appreciated his knowledge of signs indicating bad luck, but still considered Jim to be a slave and an easy victim for a joke.
all you wuz thinkin 'bout wuz how you could make a fool uv ole Jim wid a lie. Dat truck dah is trash; en trash is what people is dat puts dirt on de head er dey fren's en makes 'em ashamed"...It was fifteen minutes before I could work myself up to go and humble myself to a negger-but I done it, and I warn't ever sorry for it afterwards, neither.
By the end of the novel, Huck has completed the transformation of attitude that Twain was presenting through all the adventures.
The more I studied about this, the more my conscience went to grinding me, and the more wicked and low-down and ornery I got to feeling....somehow I couldn't seem to strike no places to harden me against him, but only the other kind..."All right, then, I'll go to hell"...for a starter, I would go to work and steal Jim out of slavery again;