There's nothing wrong with that, capitalism would even things out, a company that is sexist will make less money than one that isn't. This is because the available talent for a company is more limited if you exclude women.
To the contrary, non-slaves produce more value than slaves, therefore slavery is not only unethical, but also un-capitalistic.
Capitalism explains many things, certainly people stopped Apartheid, but it can very well be both, slavery and segregation are unproductive, and therefore anti-capitalistic.
To the slave owner yes, but their entire productivity is lower, it's better to have a businessmen rather than someone who can just pick cotton and do basic chores.
I think capitalism has a hand to play, to ignore it is naive. I think there was not one driver that ended slavery, but many things working together.
Certainly it is a utilitarian argument, but in the capitalistic sense a business (plantation) that uses slaves is less efficient in terms of net productivity of the slave than if the slaves were free and instead workers competing to improve the business.
Note: I'm not saying there is no moral reason slavery is wrong, just that in addition it is contrary to the nature of capitalism.
Capitalism rewarded the slave trade for generations.
The invisible hand is really human preferences. That's what will determine whether a company is punished for sexism or rewarded.
Humans stopped Apartheid. Not the abstract concept of capitalism.