Sexism, nepotism, and xenophobic predate capitalism, but racism does not. Racism was created as the explanation for why African slavery, which was much more brutal than prior slavery, was okay after all. African slavery in turn was because of mercantilism/capitalism. They were getting out of debt by ruining people’s lives. It was quite inhuman.