In most cases, the prosecution will agree to reduce the charge, dismiss counts, or recommend a less severe sentence in return for a guilty plea. This is known as a plea bargain. The great majority of criminal cases are resolved with plea bargains. This is because the judicial system doesn't have the resources to hold a trial in every case and because defendants generally hope to receive a less severe sentence by pleading guilty. Pleading guilty might be the best course to follow in a particular case particularly if there is no chance of winning at trial.
In some cases, evidence of guilt is overwhelming and having the best lawyer in the world isn't going to make the least bit of difference. In some cases, the offer is so meager that you have nothing to lose by taking your case to trial. Defendants are generally punished for taking their cases to trial, meaning if you elect to go to trial and lose you are likely to receive a more severe sentence than you would have received had you elected instead to plead guilty.
You should never plead guilty without knowing what the evidence is against you and knowing what the prosecutor is offering in return for a guilty plea. Your lawyer has an ethical duty to advise you of the offer. Competent counsel can advise you what your chances of are of winning at trial and what you stand to gain or lose by accepting the offer. An attorney with trial experience will have a better sense of which cases are winnable. Timing of the guilty plea is a critical factor. Sometimes the deals get better the closer you get to trial and sometimes they get worse. Experienced defense counsel should know when it's best to hold out before accepting the prosecution's offer. Sometimes a prosecutor with a heavy workload will cut a better deal at the last minute before trial. Sometimes a prosecutor will set a final deadline for you to accept a plea offer and really mean it.
Pleading guilty to a criminal offense is one of the most difficult decisions you will ever have to make. You are compelled to choose between a bad alternative and a worse one. You should never feel pressured or rushed into making a decision. Once you enter a guilty plea, it will be difficult if not impossible to withdraw the plea later on if the sentence is worse than what you expected. In most cases, your attorney cannot guarantee what the sentence will be. Make the decision carefully and avoid buyer's remorse.