There are two main reasons why prosecutors agree to plea bargain:
The case against you is flawed and the prosecutor fears an acquittal if the case goes to trial.
The prosecutor’s docket is crowded and he simply doesn’t have the time or resources to take every case to trial.