I'll just pull a random example out of my ass.
John Doe gets arrested and charged for derpery (carrying a 3-5 year sentence), but the evidence is shaky.
The D.A. offers him a plea to the lesser charge of herpery for a 6 month sentence in the hopes of just getting rid of the case.
If John Doe goes to trial, he faces a 50% chance of getting convicted, and receives an average 4 year sentence.
So if you multiply all those probabilities out, John doe should take the 6 month plea bargain, or otherwise he'll spend an average of two years in prison from going to trial (50% chance of an average of 4 years, 50% chance of 0).
This isn't far off of how real cases go, trials are almost 50/50 acquittal/conviction, so DAs tend to offer sentences somewhat less than half of what would likely be given at trial.
If the DA thinks the case has different odds, they'll adjust the plea bargain accordingly based on how strong the case is. The entire idea is avoiding the expense of a trial (and possible appeals), and of extra money spent keeping people locked up, while at the same time having an amazingly high conviction rate and appearing to be "keeping the community safe".
If you add prisons that make a profit on keeping people locked up into that, it gets far more fucked up.
Edit: My solution to it? Remove 90+% of the (amazingly silly) laws from the books that have clogged up the judicial system in the last 100 years, especially remove every "crime against society" or "public well being". Don't offer serious violent felony offenders plea bargains at all, make them all go through trials and be found guilty or acquitted, too many innocent people take plea bargains in these cases and too many guilty ones get out early. Send the guilty ones to regular state run prisons more focused on rehabilitation, with comprehensive mental health services. Completely do away with fines exceeding restitution, and civil asset forfeiture processes. Keep plea bargains in place for non-violent and minor violent offenders and sentence them only to community service, probation or for-profit halfway houses that make money off of placing them in jobs with on the job training. Automatically expunge all misdemeanor records 2 years after completion of sentence, and all felony and mental health records after 5.
I think we'd notice the "crime problem" suddenly wasn't much of a problem after all.
Also, require every new federal law to be heard in front of the supreme court before it can be enacted.