Everyone should understand the distinction between what is moral and what is not moral. I have written briefly about that here.
What is legal is not necessarily moral. What is moral is not necessarily legal. What is the relation between the moral law and the civil law? That is something every society must decide for itself. We leave aside those matters of the civil law that are unrelated to morality.
Either (1) the civil law (a) prohibits some but not all immorality and tolerates without approving some immorality, or (2) all the above plus the civil law (b) approves some immorality, or (3) all the above plus the civil law (c) prohibits some morality.
Every society should understand the moral law as well as it can. Every society tolerates some immorality (1) because they are not willing to adopt the entire moral law, either because they consider that would be impossible to enforce or because they reject the level of interference in the lives of their citizens that would be required to enforce it all.
Societies that are morally declining start to approve some immorality (2) either because think they can loosen the moral law or they think they have the power to reclassify some behavior as moral. This is a dangerous change that opens up society to immorality on a larger scale with an inclination to keep reclassifying more behavior as moral. Often it is immoral sexual behavior that is approved.
Societies that are unclear about the difference between morality and immorality begin to prohibit some morality (3). They can make themselves judges of morality and think morality should be changed because it is too strict or does not express their values. They end up prohibiting some morality and enforcing immoral behavior. Often it is immoral sexual behavior that is enforced.
The progression from (1) to (2) to (3) shows a society in decline and on its way to collapsing. History provides many examples of such societies. See Sex and Culture.