“You can’t legislate morality.”
Of course you can, and we have. As has every society and civilization; every single law on the books is some form of moral belief given the force of civil authority.
There is however a Legal System and it functions very efficiently. It consists of two separate standards: One System for the Elite, Royalty, the Blue Bloods, and the powerful. The other system is for the serf and peasants. The Elites do as they please. The serfs do as they are told.