Humans evolved in small groups, and these small groups grew, by various means, to become larger and larger groups over the evolution of human civilization. The path to the development of a large society with sufficient social harmony to be healthy and sustainable has been long and torturous and only was achieved after much experimentation with different rules of social behavior. Of course the social rules were often crafted primarily for the benefit of elites, but often enough the elites crafting the rules recognized that they would benefit from improving the general welfare of the society, particularly in the societies that survived long term. Sometimes the rules were found to be inconsistent with general welfare by later generations, or by those leading rebellions in the same generation, and were overturned or modified, but this was always best treated as a delicate process as over time human rules become entangled with the values, belief systems, expectations, and patterns of behavior that are common in the society and which members depend on as they build and maintain the web of human life.
Also, note that moral systems developed in large cooperative groups as a means for regulating the behavior of members of the group for the benefit of the group. It appears that moral systems developed before writing and before any rules were formally written or enforced as humans evolved the propensity to develop rules, based on feelings towards members of the group, to give the group an advantage. That implies that the emotional components that often accompany moral rules may have evolved long ago as a means to regulate the behavior. And that implies that any system of moral rules will increase its efficacy if its development takes into consideration the emotional components of the rules and the extent to which the rules were originally determined solely or mostly by those emotional forces. And so any system of moral rules which claims to stand merely on “enlightened self-interest” of members of the group is fundamentally lacking.
Related to that, note that in the development of civilization to allow members of a large group to live together in harmony, moral rules were formalized into laws and enforced by a central authority. These laws were designed to regulate social interactions by making explicit what the limits of acceptable behavior were, and in that sense the laws would dictate morality. Virtually every law sets limits for legal or acceptable behavior and so virtually every law dictates morality, which makes preposterous the claim that we should not enact laws to dictate morality.
Obviously prohibitions against stealing, murder, slavery, rape, assault, child molestation, drug use, fraud, etc… are based on shared beliefs about acceptable behavior and so one can make a strong claim that they have a moral basis. Now, one might argue that there are economically based laws that can be distinguished from morally based laws but that is a false distinction. Any economic goals must be based on some value system, prioritizing what is more valued in the society over what is less valued, which constitutes a system of morality.
It is not that governments cannot legislate morality, but that sometimes the totality of forces contributing to what is perceived as a social ill that should be addressed is simply too great for the legislative remedy that is prescribed, particularly when those implementing the remedy are not sincere enough, determined enough, or committed enough to devote sufficient resources, which could turn out to be substantial.