Laws are about legislating morality, whether in the tax code, or murder, a society figures out what they consider moral, and then make it law.
Let me note that laws against fornication and sodomy existed in virtually every state.
That didn't stop either from happening.
The repeal of those laws, where that has occurred, is a response to society's demands, and not any moral code (rather the lack thereof).
If a law was effective at regulating behaviour, there would be no crime. Instead, people do what they will do, the laws make sure they conceal the results as best they can from society as a whole, and morality suffers because the clear disadvantages of such behaviour become muddled in crusades over laws instead of the behaviour itself and the results of the behaviour.