The truly idiotic “can’t legislate morality” cliche was never of course meant to say any such thing.
The actual point was, “You can’t legislate sexual morality.” Or, perhaps more accurately, “I don’t think you should legislate sexual morality.”
Now this is a validly debatable point, but I think the automatic unthinking exclusion of sexual issues from discussions of right/wrong or legislation is really stupid.