In a secular state, laws are supposed to reflect common or, at least, majoritarian moral values. Civil laws prohibit race and sex discrimination primarily because civil rights activists and feminists succeeded in framing discrimination as a moral wrong. Criminal laws punish behaviors widely acknowledged as immoral--murder, rape, and other violent assaults and burglary and fraud. As a general rule laws function most effectively when the moral judgments they reflect are widely shared: prohibitions of abortion, marijuana use, or pornography are quite difficult to enforce because many people consider the legal prohibitions themselves more immoral than the behaviors they proscribe.
I'm not lamenting the moralism inherent in law, as some secularists do, shortsightedly. (People generally complain about "moralistic" laws only when they don't share the particular moral values the laws are intended to enforce.) Legal moralism is inevitable and not inherently inappropriate. I defend freedom of speech and religion, for example, because I consider censorship and religious persecution essentially immoral, not simply impractical. Of course not everyone shares my values; of course I …