In my opinion, equality and due process are the most important elements of fairness in a legal system, and these are provided in the document that created our legal system, the Constitution and its Amendments.
A system of law in which people perceive that they will not be deprived of "life, liberty, or the pursuit of happiness" without being treated equally is a system that works because everyone is subject to the same rules and sanctions, at least theoretically. People might not be happy with the consequences, but if everyone faces the same consequences, then there is a perception of fairness.
Due process is also central to the notion of fairness in the law. What is due process? Due process is the hoops government must jump through before they can take away your life, liberty, or pursuit of happiness. For example, you cannot be imprisoned or fined unless you have a trial, a knowledge of the charges against you, an attorney if you want one, the ability to call witnesses for you, the ability to confront and cross-examine witnesses against you, and so on. No one can put you away or take your money without going through all of these steps and more. Having due process built into our legal system provides us with the perception of fairness because it is meant to assure us that the government cannot act arbitrarily against us.
As long as a society perceives that its legal system is fair, it will conform (mostly) to its requirements. When a society begins to feel that the legal system is unfair, it is less likely to hold up its end of the social contract.