We could just let the market decide, and since we know the antiracist hypothesis is true, racist companies would miss on a huge amount of qualified labor and get beaten in a free market, forgetting for a moment that free markets are a myth and don't exist, and that the markets we do have aren't even close to efficient.
But we don't. We force companies to act a certain way even though they don't wish to because we are forcing ethical standards on them. This is, akin to your point at the expense of all of the workers not protected by the law. Every time we prevent a black person from being fired because he is black, it's at the expense of the white person who would take his job. The costs are passed down to white people. Neither choice is completely without consequences, yet we've made the one against racism.