In fact, the only legitimate reason for passing any law is that it will result in a positive moral outcome.

Of course, it may not result in a good outcome. It may result in a wicked outcome. Legislators may be influenced by all kinds of evil. Or they may be trying very hard to pass a good law, only to find out later that it was terrible decision. Nevertheless, this does not affect the basic point: The only legitimate reason for passing any law is that it will result in some positive moral outcome.

Even laws that could be otherwise are intended for a moral purpose. For example, in the United States people are required to drive on the right side of the street. We could drive on the left, and it might work perfectly well, but we've standardized on having people drive on the same side of the street because we value human life and we don't want property destroyed, both moral principles.

For some people, it may appear I'm attacking a false foe, because what they're thinking when they say, "You can't legislate morality" is not that laws shouldn't promote the best interests of people, but that, "You can't stop people from having sex."

But I doubt if they really even mean this, for in my experience they don't intend that we should do away with laws against rape or child molestation - both instances of people having sex.

I think what they really mean is that it would be immoral to pass laws against particular kinds of sexual behavior. If I'm right in thinking this is what they mean, then we've come full circle. We're discussing (as we should have been all along) what is right and wrong, good and bad, moral and immoral, just and unjust.