People like to have rules and thus laws, because they create order in society. They help each person to have a sense of security, as laws tells what is expected of them and what they can expect from others. As the law is based on custom, it also reinforces the values of the members of the society. It says that what individuals feel is important and has importance to the larger group. Laws also have a function of providing protection for all members of the society, not only their own actions, but those of others. Laws tell society what actions are not allowed. They also provide freedom to do things by telling society what actions are allowed. In addition they resolve disputes as they have penalties for behaviour which goes against the law and empowers the police and the courts to enforce and administer the law.
People will not follow rules if they do not agree with them or see that they have no connection to them. This is especially so if the penalty attached to the rule is seen as inadequate (for example, standing on the wrong side of the escalator has no penalties). However, as laws do have the range of penalties attached to them, it will make a person think twice before breaking the law, people are more inclined to follow the law.
In the absence of law a state of lawlessness would occur, also known as anarchy. So during anarchy laws will not keep the relationship between people and society harmonious, which is the fundamental of running a strong society.