In the 1600s, European powers were transitioning economically to early capitalism while also exploring and colonizing the world. This exploration allowed for great opportunities for trade, resource extraction, and exploitation. Combined with the emerging capitalist system, it created great potential for profit to flow to tiny elite that controlled land, trade routes, industries, and military forces. Hungry for gold and fame, European explorers landed in Africa, America, and the Caribbean, finding in the latter highly valuable crops: sugar, tobacco, cotton--and in the former a source of labor: slaves. This was the beginning of the Triangle Trade.
Slave ships filled with gold and trade goods left Europe for Africa where they purchased slaves. They sold these slaves at a profit in Caribbean colonies like Haiti or American plantations where the slaves would be worked to death to produce vast quantities of valuable cash crops. The coffee, sugar, and spices would be returned to Europe to be sold at an enormous profit, which would be invested into more slaves so the cycle could continue.
In the early days of the transatlantic triangle trade, the concept of "racism" wasn't exactly how it is in modern times, but the idea still existed. European explorers and traders were certainly exploiting, enslaving, and killing people to help turn a profit, but a hatred based on skin color was not their sole motivation; money mattered most to them.
Over time, the profitability of the triangle trade came to be threatened by moral misgivings over the intense exploitation taking place. A Haitian sugar slave might be worked to death in only seven harsh years. So, it became necessary to invent justifications for why these African slaves could be exploited to protect highly profitable industries. There were many myths and justifications dreamed up through this era: Paternalism, the Curse of Ham, and stereotypes of black people as lazy, unintelligent, or violent. The stereotypes that exist today are the result of this period and were created to protect the profits of the slave trade.
The slave trade ended in the 19th century, but American slavery continued until the Civil War, remaining hugely profitable. The value of all the slaves held in America in 1860 would be worth trillions in today's dollars. Therefore, racism remained necessary to protect that value and profit. After the Civil War, racism remained a useful tool to keep former slaves down, and crucially, to keep white people from working together with slaves to form a working-class movement. Such a unified movement terrified and still terrifies the US's economic elites. Perpetuating racism keeps poor whites hating poor(er) black people instead of the small group of people stealing from everyone else.
When a poor rural farmer identifies more with a New York billionaire than a Mexican-immigrant laborer, that is the power of racism at work protecting capital. Though both previously mentioned people share the same class position and class interests, the poor rural farmers has been inculcated into a system of hatred based upon the spurious theory of biological race. This harms everyone except for the New York billionaire who exploits both workers' labor to accumulate wealth. As long as capitalism persists in America, we will not be able to reckon with our racist culture because to admit the truth about racism would fatally undermine capitalism.
Racism is a product of historical and economic circumstances under capitalism. Here today, the history of capitalism is so bound up with the history of racism that they can no longer be separated. Race remains such a powerful tool to divide people that capitalism will always seize upon it. Racism cannot be truly defeated until capitalism is overthrown.