The role of government is not to avoid unnecessary pain. Government is a collectively formed institution given a set of powers to provide goods we cannot provide for ourselves individually. There is no objective reason why people, acting through their government, have a right to violate the rights of others, when clearly people have no such right when acting in the individual capacity. They do not have a right to make racist motives or hiring practices illegal, because it hurts their feelings.
And trivializing the harm done by racist hiring practices is disingenuous. Its not just 'hurting feelings'; its marginalizing citizens en masse.
Many practices, like slavery, that we now consider deeply immoral, were in place for thousands of years before the majority came to believe in their immorality. The fact that something has been done throughout history neither tells us it is moral, nor that it is immoral.
I think if you strip away the ideology (modern liberalism), the labels (government) and the appeals to convention ("this has been done for hundreds of years"), and look at the practice you are endorsing for what it is, it is clear that it is immoral.
You're saying that you and I have a right to threaten John with violence, because John won't hire Rhonda due to her race.
That is what all government mandates are based on: violence, and you want to use them to make actions that in no way violate another party's rights subject to violently enforced punishment, if they are based on a particular set of values, or refuse to help a particular party we want helped.
But most government most place most of the time its just social pressure. Fines for parking in the wrong place. A visit from a social worker. Lines painted on the highway.
Jumping from those to violence is disingenuous.
Something being the law doesn't negate its qualities. The law is enforced through the threat of violence. Ignoring this fact is euphemizing what your political ideology is actually endorsing. The fact that laws are enforced through the threat of violence is extremely important, because it tells us why a humane society does not use the law to punish consensual activity or noncompliance with morally illegitimate demands (e.g. the demand by income tax law on the population to surrender its private property and privacy rights).