The lawyer's job is to insure that everyone is held to the same standard of the law in the US. Even if you think your client is guilty (or you know he is guilty), you are there to be sure that all the evidence and testimony used against him is the same nature as that used against other persons.
O.J. Simpson walked away because of the deplorable job the police did when they investigated the incident and the sloppy way they collected and controlled the evidence.
If we said, "Who cares, the guy is guilty" then we open up the possible that the police can just manufacture evidence in any way they want to put people in jail or send them to the electric chair.
It is the attorney's job to see that corrupted evidence is exposed and cannot be considered in the case.
If we consistently allow first time petty theft criminals to work a plea deal to avoid prosecution, then an attorney makes sure that his/her first time petty theft client receives the same advantage that all the others have.
It's not always about insuring that everyone is punished for every law that is broken, it is about insuring that all people are being treated equally in the judicial system.
There are folks who say that the attorneys who defend "obviously guilty" people are just doing it to get high fees and get rich off the system. Just as there are racial bigots and sexists, there will always be people with those opinions of attorneys. That doesn't make them right.
And if you want to send criminals to jail, then once you are an attorney you have to join the District Attorney's office, because that's who handles criminal cases. Beware that if you are a really good attorney, you will make far less money working as a prosecutor than you would if you were with a private law firm.