One of the most undeniably racist and immoral systems in history was South Africa’s apartheid.
Laws were engineered to disadvantage and oppress non-whites.
However, even racist laws in South Africa were circumvented when firms were motivated by profit.
There is a cost to discriminate.
In competitive markets, this cost helps determine the price of labor.
In non-competitive markets, the price is fixed (usually by the government).
This makes discrimination MUCH easier…