This has been a common phrase used for decades, and i think its wrong. Every law that our govt has made has been in the spirit of being morally right. Im not saying govt always gets it right, but what if they did try to legislate morality? Would it really be so bad??
I think the problem with that would be, freedom only works with moral people. And America is anything but moral or free.
I don't believe every law has been in that spirit. I believe many laws are driven by political and corporate interests.
Morality to you and I is the Word of God.
But for a godless person morality is whatever suits them. It's whatever they feel is right. Adultery, abortion, promiscuity, LGBTISM, and such.
So I would ask who is making the law. If it's coming from godless atheists then this is what we get and there is no way I'm going to adhere to godless laws.
But even as Christians we often can't even agree on what is right and wrong. At the moment many think that persecuting and discriminating against the unvaxed is right while I have always believe that discrimination against innocent people is wrong.
So to your question about legislating morality I would say no because morality is subjective, unless the moral issue being questioned is agreed upon by all. Eg, murder is wrong