Same might be said of logic. Law has a logic of its own.
Orange trees are not particularly closely related to apple trees.
The further from morality any particular law is - especially if it has little rational basis (in the logical sense of that phrase, not the Constitutional Law sense), the less likely the average person is to obey it. Witness Prohibition and the 55 MPH speed limit. All that laws like those do is to encourage contempt for ALL laws.