Well, remember the principle of ‘double effect’ - one can employ imperfect methods to achieve a good, there being no better (and certainly no other) alternative available.
We know, being fallible humans, that the justice system is fallible and inevitably will punish some innocent people. But what would you suggest as an alternative? Leaving criminals totally unchecked and unpunished? We need a legal and judicial system, and we have, over the centuries, come up with the best possible system. There are all sorts of measures and rules of procedure and such employed to safeguard defendants’ rights, including the system of appeals and other checks and balances on prosecutorial and judicial power.
Above all we don’t make a habit of KEEPING wrongfully convicted/jailed and demonstrably innocent people in the courts or in prison, do we? Rather we acquit or release them.
Think of Rubin ‘Hurricane’ Carter (recently saw the film made about his story) who was convicted on wrongful evidence manufactured by malicious prosecutors. Albeit that it took many years for him to be able to adequately demonstrate the falsity of his conviction, once he did so he was acquitted and released, and probably eligible for compensation of some kind too.
Similar case here in Australia - Lindy Chamberlain (although there wasn’t really the element of malice in her case, there certainly was unreliable evidence), she too was released and received compensation.
And having done some work experience on the public prosecution side of things, I can assure you that I have seen courts almost literally bend over backwards to ensure that defendants are given due process, and am convinced that many guilty go free on technicalities for every single innocent person who may be wrongly convicted.
And we DO criticise, and even fight wars against, countries that have notoriously corrupt judicial systems, no?