The theory is two sides produce the absolute most convincing argument they can, and an independent arbiter - the jury - decides between the two arguments. As both sides can freely choose their representatives, they can change if their guy isn't doing a good job. And as the jury has heard the strongest possible arguments, they've heard all the information the two sides believe they need.
If you're accused of being gay in 1880, a randomly selected truth-seeking arbiter might be very anti-gay as that was the median opinion in society at the time - or even subject to political pressure. Only by having free choice of who represents you can you get someone who isn't biased against you.
Of course, that's only the theory. How well it works in practice, particularly with under-funded public defenders, is a different matter!