Any law which compels an actions which is not right is a bad law and should be changed.
That does not imply, however, that every action which is not right should be forbidden by law.
Indeed, the very essense of God's gift of free will is that people should have the freedom to do that which is right or that which is wrong, subject only to the constraint that they do not interfere with others' rights.
The father of the Prodigal Son loved his child enough to let him go and discover his foolishness for himself. Though it might have been easier for the father to keep the son at home and refuse to let him leave, the son would never have gained wisdom had the father done so.
In a perfect world, there are no laws, and everyone is free to do as he/she pleases because all do what is right.
In our present world, laws sometime are necessary to establish what is right and to keep an orderly society.
I'm sure the father of the prodigal son would have been outraged if the King/government of his day signed a decree making pornography legal.
No doubt the father would have thought that the King had lost his mind.