In a free society—populated by real people—racism, sexism and other manifestations of ignorance and fear not only survive, but are voiced and propagated. That is the tradeoff: if you preserve freedom of speech—which is really freedom of thought—you preserve the presence of love and hate in the minds of the citizenship. It cannot be any other way. To attempt to stop people thinking and saying certain things is a violation of free speech; censorship of unpalatable opinions and “wrong” ideas is still censorship.
So, what does a government of a free society do? Many things, but it certainly doesn’t act as thought police, attempting to corral ideas. It is the government’s responsibility to preserve our ability to say whatever we want. But this only works when the governmental upkeep of free speech is coupled with the continued education of a people. Government can’t and shouldn’t police thought. That job falls to citizens at the individual and collective level. Let me give you an example.
We know smoking causes cancer. We know that it harms not only the smoker, but anyone in the vicinity. The government know this, but they cannot simply outlaw cigarettes. Instead, they must trust to the expansion of our collective understanding. It’s become common knowledge that smoking is harmful, so we frown upon people smoking in restaurants. We take issue with pregnant women toking away. Cultural pressure and collective education polices what, and where, governmental instruments cannot.
The same process happens with ideals of equality, justice and truth. The government can try to embed these things as part of the law, but more effective is our understanding that these things are right. Explicit racism in the first world is generally recognised as bad, so it is socially discouraged. Hitting children is no longer socially acceptable, so it doesn’t happen as often as it used to. Women are not treated like trash by their husbands because the illusion that women are second class citizens is fading and dissolving.
Essentially, when it comes to human rights like the freedom of speech, governments must act as referees, intervening only when the right itself is threatened, not when the right is used to peddle a perspective it—or the majority it represents—does not agree with.