Ron Weasley’s character is consciously written as somewhat racist. Not as racist as Malfoy, of course - he doesn’t scoff at mudbloods and halfbloods, and he doesn’t see himself as superior at all. Still, he unquestionably accepts the inferior position of house elves (they love serving), when he finds out that Lupin’s werewolf his reaction is not only scared but also disgusted (Don’t touch me!) and he is clearly very uncomfortable finding out that Hagrid is half-giant (giants are wild and savage).
And this is brilliant. Because it demonstrates that racism isn’t only present in clearly malicious and evil people, in the Malfoys and Blacks - it’s also there in warm, kind, funny people who just happened to learn some pretty toxic things growing up in a pretty toxic society. And they can unlearn them too, with some time and effort. Ron eventually accepts Hagrid’s parentage, lets Lupin bandage his leg and in the final battle, he worries about the safety of the house elves.
Some people are prejudiced because they are evil, and some people are prejudiced because they don’t know better yet. And those people can learn better, and become better people. And that’s an important lesson. The lesson taught about discrimination shouldn’t be “only evil people do it”, because then all readers will assume it doesn’t apply to them. Instead old JK teaches us “you too are probably doing it, and you should do stop ASAP”.