What is the purpose of law?

The purpose of a law is to maintain public order and control. Another purpose is to ensure justice has been served.