Chewy, that's not how thought experiments work.
Personally, I think that letting them all go seems to be closer to the concept of justice. Making sure that innocent people aren't punished for crimes they didn't do is more important.
Most justice systems don't work in that way, even though they like to claim they do. Instead, criminal laws seek to be efficient and pragmatic: if 1 innocent person goes to prison, it's worth it to catch the 99 bad guys. Three innocent, well, you still have 97 bad guys. I doubt lawmakers or the system would care until you got to about 15 or 20. When you make exceptions to protect good people, several bad people take advantage of the exception to go free. It all comes down to how does one write a law, how do courts interpret the law, and how does it all play out over a series of cases. You can't get this perfect: the only way to keep every good person from going to jail is to prevent every bad person from going to jail as well. The question is where do you draw the line, and the answer is that nobody fucking knows. Because of this, lawmakers, judges, and prosecutors really don't have a problem sending innocent people to prison, because it is an inevitable part of any criminal justice system.
But Lizard's post reminds me of a hypothetical in my criminal law class. A man savagely rapes a minor teenage, minor girl. After fleeing the scene of the crime via car, with police in hot pursuit, he crashes the vehicle doing extensive damage to his junk and causing mild brain damage that largely removes his violent and savage tendencies. Because of this, there is literally no chance that he will ever rape again: he is, by account of his accident, 100% rehabilitated. Should the court dismiss his case or try him for raping the girl?
I know some people will naturally say "No, the state shouldn't punish him." I think most people--although certainly not all--who give that answer are lying to themselves. Because of this, and innate flaws with the concept of rehabilitation (and it's noted racial biases), I think retribution is the most common sense and intuitive purpose of the criminal justice system... And I don't like it, but you can't unlearn what you know, you can't close pandora's box, and you can't put the toothpaste back in the tube.