Laws can be described as a systematized set of rules that people adhere to based on the social contract that they enter into with their society. Due to the necessity of limiting chaotic activities, the individual action of people are curtailed under laws to better adhere to a state of being that results in a peaceful society. Thus, if people wish to reap the benefits of being part of a particular society, they need to follow the laws that govern their people through social institutions. Violations of the social contract, like any contract, come with penalties with more extreme punishments culminating in death or life imprisonment.
A lawyer knows that his client is not innocent of the crime he is defending him for; however, under the law, he is to represent his client to the best of his abilities and not outright violate his oath to not disclose what his client has said to him.