Well from an objective perspective, humans being racist are the same reason there are picky eaters.
Back in the wooden dildo days we would have to find food laying around in the woods because hunting was too inconsistent. So we evolved to start eating only foods we know are good, this was to avoid us trying every plant in the forest and dying. For the tiemjs we did explore new foods, it was taken in very very small proportions to see if it gets us sick. Notice a very picky person trying something new will feel disgusted and at most try a little bit of the new food. This is a natural biological response in humans to avoid getting poisoned.
When it comes to racism the same concept applies. We naturally suspicious of those who are different than us, and for good reason. People like the native americans would see Europeans and be run away from them. Because they were different, and guess what happen to those that tried treating them like their own? They were killed or enslaved. This has been going on all of human history, so it's literally in our DNA like you said to be racist, but not just white people. All people.