Your question presumes that prosecutors are looking for the truth, right and wrong, innocence and guilt.
They are not.
Their job is to prosecute. Hence we've seen terrible stories about people prosecuted and jailed for years because prosecutors knowingly refuse to turn over exonerating evidence.
Judges are also part of this problem. They are paid by government. Their instructions (Rules of Criminal and Civil Procedure) come from government. They have often worked as prosecutors for the government. So their loyalty is to the government. We don't have an independent judiciary. It's been wholly captured by the government.
Getting to the question as to why the innocent plead guilty, when you're faced with the cost of an attorney it's often cheaper and easier to take a plea than to fight. The stress, emotional and mental toll of a legal fight are horrendous. And there is very little guarantee that a defendant will win.
The deck is stacked against you when you go to court. Prosecutors and judges are not there to have a colloquy about the law, the facts, the issues of the case, nor to debate the motivation and intent of the defendant. The prosecutor is there to win. The judge is there to ensure that the well-oiled machine keeps running and that jurors deliver the needed verdict.