Prejudice is entirely rational if one doesn’t have a soul. The only reason we regard the poor with any consideration is that we know that God asks good from us. Its not a question excess of compassion.
Sexism and racism, as well as ageism, beautyism, etc., are not bad things. They are like other tools. They can be used for bad or for good. I was quite sexist when choosing a wife.
The basic component of intelligence is pattern recognizition.
For example, any AI that is taught to recognize patterns can look at the FBI crime statistics and and figure out certain ethnic groups commit crimes at much higher rates than others. In fact, any AI that couldn’t do that also wouldn’t be able to detect correlation between smoking and lung cancer, and would thus be completely useless.
The problem is, certain political groups have made noticing and acting based on this detected pattern “racial profiling” and “racist”. When in reality it’s just common sense.