This inane argument breaks down when you get to popular crimes. The populous does not self regulate on every action which is detrimental to society.we most likely don't need them to stop MOST people from committing murder.
Besides all a law really is is to say this is the penalty for action X, you are not the one assuming laws are moral functions, they are merely a system of rules and penalties devised for the smooth running conduct of a society.
In light of this what you are actually saying is "we don't actually needs laws except that we need laws"
HRMMMM. I wonder if there are any examples of laws that got enacted before the majority popular support was behind that cause. I wonder where I could find such an example!how do laws get passed though? Ironically, some majority vote is taken at some steps in the process anyway.
Long story short, laws should not be based on mob sentiment, they should be based on careful, reasonable and conscientious analysis of the facts, the contingencies and the repercussions.
In the specific case of racism laws, you actually do have to legislate because base human instinct and nature is to be subliminally or consciously bigoted against those that look different from you, that's unfortunately just an irrational upshot of our biology, so you do need be careful to protect minorities within your societal structure.