After years of legal drama and claims of bias, a judge ruled the prosecution’s case was too procedurally compromised to go to trial.