The maximum penalty does actually happen though, it's just not common. The problem is that you don't know if it will happen to you before the trial, so its existence is extremely coercive. It scares the crap out of people -- and people are risk averse. They'll take a 100% chance of 2 years over a 1% chance of 30 years, even if the expected value is lower, because on the off chance the coin comes up tails six times in a row, they lose their entire life.
The issue isn't the plea bargain itself, but the incentives to make lots of 'suboptimal' deals. I've seen similar, recent arguments about whether #MeToo perpetrators should be allowed to settle with victims, because of our public interest in identifying attackers.
All things being equal, negotiated resolutions are great. But politics, over-criminalization, career incentives, and budget pressure swamp any real negotiating power by defendants. No one wants to kill any individual's deal. But the deals are the best way to 'see' the effect of the system's incentives.
[1] https://www.jstor.org/stable/4093405?seq=1#page_scan_tab_con...
https://www.jstor.org/stable/796954
https://reason.com/archives/2011/07/05/the-devils-bargain
https://www.nytimes.com/2011/09/26/us/tough-sentences-help-p...
https://www.nytimes.com/2012/03/11/opinion/sunday/go-to-tria...
https://www.nybooks.com/articles/2014/11/20/why-innocent-peo...
https://www.themarshallproject.org/2014/12/26/plea-bargainin...
https://www.wsj.com/articles/the-injustice-of-the-plea-barga...
https://www.theatlantic.com/magazine/archive/2017/09/innocen...
https://www.injusticewatch.org/interactives/2018/plea-bargai...
If this answer is not satisfactory to you then perhaps you could tell me what you’re after. Because as far as I can tell, this is a really simple question and answer. What is unjust? Punishing people for asserting their right to trial. Boom, done. If you want more, ask for it.