The settler-colonists and European slavers began with leveraging a small technological gap with African states in order to start the slave trade, which was effectively nonexistent prior to European contact. They would trade goods African states could not yet produce near exclusively for slaves, which began the underdevelopment of Africa. As the slave trade emerged, so too did the need for justification. See Walter Rodney's How Europe Underdeveloped Africa for an excellent overview of this history.
This is what began the systemic dehumanization of Africans and indigenous peoples, alongside the fraternity among European nations. Racism emerged because it needed to in order to justify the existing economic reality of chattel slavery and genocide in those participating in it. In other words, the way we produce and distribute, the way we labor, the way we exist socially, determines our consciousness. Racism is not human nature inherently.
Human nature is malleable, and therefore a better, kinder world is possible. Humanity is not doomed to endless racism and brutality for eternity.