Of course, the legal system is based on the idea of discovering the truth and administering justice. Unfortunately, that is rarely how it functions these days. In the US, and in most of modern society, the practice of law has become about winning. Facts are often hidden or distorted.
Mahatma Gandhi, the Indian spiritual leader, was trained as a barrister, a British lawyer, and practiced law in South Africa (then under British rule). He was defending a man charged with embezzling, with stealing money from his company. At the beginning, Gandhi thought his client was innocent. In the middle of the trial, he heard new evidence, and realize that this was not true. Immediately, without asking his client, he announced his client's guilt and requested the mercy of the court. Things worked out well. The man did not go to prison, and worked to pay restitution instead. Gandhi's response came from his understanding of ancient Hindu law.
In the US, Gandhi would have been disbarred - disqualified from being a lawyer. Criminal defense attorneys often know that their client is guilty, and are not allowed to tell the court or anyone - a matter of attorney-client privilege. This is a good idea in itself. But, with many other complications piled on, unfortunately, the American legal system has become a place that is more about obscuring the truth than honoring it.