Let's say the sentencing range after trial is 20 to 60 years (typical across the USA).
Let's also say you killed someone with a gun. That might add 25 years onto the base sentence (e.g. Illinois).
The prosecutor comes to you and says "If you go to trial you're facing 45 years minimum from the judge. Might be 50, 60, 70 years. Trial is a lot of work from my office, and a lot of money. We're going to have to bring in forensic experts and go through reams of police reports. I have a lot of other criminals that need my time, so I'll do you a favor. Plead out for 30 years today."
Also, murders can easily take five years to get through to disposition. Look at Cook County, you have Augustin Toscano who still hasn't got to trial after 15 years.
In that time you are sitting in a county jail. County jails generally have, by far, the worst conditions of any institution a prisoner can be held in. I deposed a warden once to ask him why. "Because these are short term facilities. The average stay is under 30 days. In fact, most people stay less than 48 hours." This is because they bond out, so the stats are skewed and don't provide for the edge cases.
Everybody in a county jail wants to get out of a county jail at almost any cost. I remember a case from a few years back when a homeless guy was snatched up coming out of a food bank with a bag of white powder. He was charged with possession of cocaine and he plead guilty and was sentenced to ten years. Just before shipping out to the big house the test results came back: it was powdered milk. The judge asked him why he plead guilty. "Because I couldn't stand another day in the county."