Both racism and illegal immigration have been enormously beneficial to capitalism.
In human history, the idea of biological inferiority only became widespread alongside the rise of the African slave trade, as traders and merchants needed a justification for the enslavement of millions of people who were neither prisoners of war nor individual debtors (the traditional justifications for slavery among Europeans). Perpetuating the myth that blacks were little better than animals allowed organizers and participants in the slave trade to reap colossal profits from free labor with impunity. Racism served the monetary interests of a certain few.
Even after slavery ended, racism was used to justify further oppression and wage theft by the capitalist class. Just as emancipation would mean the end of free labor for slave-owners, human equality would force business owners to pay blacks the same wages as whites. Racism served to prevent this, just as sexism and xenophobia prevented the same for women, undocumented immigrants, and non-whites in general. In Communism and the Negro (1933), New Yorker Max Shachtman (head of the Worker’s Party) wrote:
The ruling class is in urgent need of the theory of racial inferiority… It affords them a moral justification for the super-exploitation and persecution to which it subjects the Negro. If trifling sums are allocated for Negro education, he is, after all, “only a nigger.”; if housing conditions are abominable, if the Negro is scandalously underpaid, if he is deprived of every democratic right, he is, after all, an inferior who does not deserve or require better; if he is hanged from a tree and riddled with bullets, or soaked with oil and burned to death by a mob of savages, it is, after all, “only a nigger” who suffers.
Racism served capitalists a second way: it discouraged workers of different colors from uniting and unionizing to push for higher wages, shorter workweeks, or more decent working conditions and treatment. There was racial hostility in the competition for work, and corporations often responded to strikes by hiring unemployed blacks to replace white strikers, as they could pay them dismal wages with less threat of resistance. The racial tension and violence this created impeded the progress of interracial organizing and helped keep the working class poor.
Prominent black leaders saw the connection between racism and capitalism. Malcolm X said, “You can’t have capitalism without racism”; Stokely Carmichael said, “Racism gets its power from capitalism”; and Dr. King said, “The evils of racism, economic exploitation, and militarism are all tied together.” They knew that racism served capitalists’ financial interests, whether consciously or as a matter of course.
Illegal immigration has likewise enormously benefited capitalism, both in the U.S. and worldwide, in a similar way to how racism benefits capitalism. In the U.S. it is illegal to hire undocumented workers; employers do so regardless, particularly in the manufacturing, construction, agriculture, restaurant, and service sectors.
Illegal immigrants are some of the most exploited workers in history. (See Amnesty Solves Conservative Criticisms of Illegal Immigration for more on this general topic.) With employers holding the power to fire or turn them in to the authorities, undocumented workers face dismal pay, harsh working conditions, and an inability to organize and unionize to improve their position. They are not entitled to a minimum wage, nor benefits, nor overtime, nor child labor protections, nor in most states injury compensation. In 2008 authorities discovered children as young as 13 working in an Iowa meatpacking plant, and beaten and bruised adults working 17-hour days.
Alan Maass writes:
For corporations and the U.S. political establishment, immigration has nothing to do with making opportunities available to the world’s poor and suffering. Like slavery in an early era, the key is how immigration guarantees a pool of cheap and easily controlled labor.
If you look at the history of the United States, the idea that immigration controls and border security are about keeping immigrant labor out is laughable. For two centuries, one group after another was encouraged to move to the United States under conditions of illegality, and be the scapegoat at the bottom of the heap. Irish, Jews, Germans, Swedes, southern Italians, Eastern Europeans, Asians, Mexicans, Central Americans, Muslims…
Capitalists can increase their profits by taking advantage of millions of people, again whether intentionally or as a natural, inadvertent consequence. Capitalism benefits from a steady flow of illegal immigrants.
It is very interesting to note that in this case the ideology of anti-immigrant conservatives does not align with the interests of capitalist power. So often conservatism serves corporate interests, such as the hostility toward environmental protection regulations and the opposition to the minimum wage.
But here racism benefits capitalism in one way and hurts it in another. Virulent racism allowed for the super-exploitation of certain groups of people, but also created masses of racist people who opposed the arrival of blacks, Jews, Greeks, Italians, Hispanics, etc. throughout American history. Most all non-Western European immigration, legal and illegal, has been opposed because of bigotry at various times. The current anti-immigrant hysteria certainly has a racial component. In sum, while capitalism benefits from illegal immigration the same racism that also benefits capitalism encourages people to oppose illegal immigration, screaming for deportation, patrolling borders as vigilantes, and calling for the construction of massive walls.
 Schachtman, Communism and the Negro
 Maass, The Case for Socialism