A lawyer can make suggestions to the court. As long as there is a certain factual basis, the judge is very likely to adopt the lawyer's suggestion. It turns out that the more serious crime A may be sentenced to a lighter crime B, because Many things are not black and white, so lawyers generally function in gray areas.
There are also some less serious civil lawsuits, such as divorce between husband and wife. A good lawyer can win more marriage rights for the parties, as well as child custody rights, etc.
Therefore, the presence of a lawyer is necessary.