To expand on this, plea deals are most common for poor defendants. The police convince a magistrate to set cash bail the defendant can't pay, and the defendant has the choice of taking a guilty plea for a "lesser charge" or sitting in jail for months until the case can be tried, at which point they are defended by an overworked, overwhelmed public defender.
In many cases, the potential sentence for these cases is exceeded by the time they would actually spend in jail waiting for the trial; even being found guilty would result in time served. In these cases, the plea deal is literally a lesser sentence than being found not guilty.