Morality is the sense of judgment between right and wrong reference to certain standards developed society over time.
It defines standards of behavior widely accepted a society and is binding on the conscience of the members of that society. An action that is considered to be opposed to morality will generally be frowned upon that society. However, morality is not enforceable courts of law.
This is compared to rules of law, which are binding, enforceable and have sanctions in all cases. Wrongs in society are contraventions of law or morality or both. However, the law incorporates a significant proportion of morality. In such instances, where law and morality overlap, morality is enforced as a rule of law. Such morality becomes part of the law. E.g. Killing a person is immoral as well as a crime. So is theft.
However, certain wrongs in society contravene morality but not the law e.g. disrespects failure to provide for parents, failure to rescue a drowning person e.t.c.
What then is the relation of morality to law?
1. The existence of unjust laws (such as those enforcing slavery) proves that morality and law are not identical and do not coincide.
2. The existence of laws that serve to defend basic values such as laws against murder, rape, malicious defamation of character, fraud, bribery, etc. proves that the two can work together.
3. Laws govern conduct at least partly through fear of punishment. When morality, is internalized, when it has become habit-like or second nature, governs conduct without compulsion. The virtuous person does the appropriate thing because it is the fine or noble thing to do, not because not doing it will result in punishment.
4. As such, when enough people think that something is immoral they will work to have a law that will forbid it and punish those that do it. However if there is a law that says doing X is wrong and illegal and enough people no longer agree with that then those people will work to change that law.