Ethics is a branch of science that concerns what ought to be.
Law is a branch of ethics that concerns with the use of violence in social interactions.
Morality is a personal code for people to adhere to.
The principle that legality does not equate morality is about separating what constitutes a law and what is moral.
A government can make a law stating that something illegal or legal. But that doesn't mean it's moral.
The natural law can also deem something legal, but it doesn't mean its moral.
That's what I was getting at.