Going all the way back at least to our Australopithecus ancestors, if not much, much further than that, how tightly tied to the other members of your tribe, has had a major effect on the survival rates of your grandchildren. This made viewing outsiders with suspicion a survival trait. But outsiders have the same enemies you do, and fighting them without need was anti survival, so tolerance was also a survival trait. Evolution has been refining both traits in our species for several million years because our survival has always depended on us having both in the right proportions. It still does to some extent, but that is a different topic.
This, us and them, is so built into us that you always gravitate toward people with similar looks and outlooks and away from those with different ones, unless you make a conscious effort not to. This kind of racism is built in by millions of years of evolution, and isn’t going away, no matter what laws or cultural changes might be in place. People will always congregate into the us and them groups, and have more suspicion of those in the them groups. One of the worst things people can do is to act as if this was not a factor and believe that they don’t do it. Ignoring this almost always increases the likelihood of violence as you disregard that they are different with different priorities, yet that is the overall most common reaction.
Far too many people have this strange idea that racisms is taught, and if those people would just quit teaching it, it would just go away. Nothing could be further from the truth. For most, only what groups are and how you will classify them changes, but you will still group people them into the us and them, and judge the them far more harshly. The very few that don’t see everyone as us and them are generally considered sociopaths, and outcast from every group and attacked from all sides as dangerous.
More or less, evolution saw to it you will look at everyone as us and them as your normal default. You don’t really get a choice in that. But how harshly you judge the them, and what actions you take after, that is generally leaned. That much the crowd that thinks racism is leaned did get right. The us and them is the why we can effectively group together and get things done and without it, very little gets accomplished. But we need to control it so is doesn’t become hate or just an excuse to force our ways on others that don’t want them. You start by seeing that you and every other person on the planet groups and judges people.