In the United States, a public defender is an attorney, paid with taxpayer funds, to provide a defense to those persons who are accused of crimes but do not have the financial resources to pay for a private attorney. Public defenders generally are employees of the government, and have the exclusive, full-time job of providing legal counsel to defendants who are assigned to them by a judge ("court").
Public defenders are paid by the State (or Federal) government, but their "client" is not the State; their client is the unwealthy defendant who has no other choice for legal counsel. Their client didn't choose them and they didn't choose their client.
Public defenders are in an unfortunate position, if popularity is important to them. The prevailing stereotype of the public defender is somewhere near that of a used-car salesman; they are reputed to be fond of polyester, tacky ties, and cheap shoes. They are not known for their charm. And the stereotype goes that they just couldn't make it as private attorneys. This is the stereotype propagated from the defendant's side.
Of course, there's an alternative unfair view of public defenders: that they make their living by freeing criminals on legal technicalities. They are seen as having chosen a profession that is slimy, unjust, and deceptive. Their job is to help stop the criminal justice system from doing its job.
This second view seems to stem from a misunderstanding in American culture about what the goal of a criminal trial is. Many people to whom I have spoken about this seem to think that it is the job of a court (or jury) to determine whether someone has committed a crime or not.
But that's not the stated purpose of a criminal trial. To be able to know for sure whether someone has committed a crime would take omniscience. Instead, the jury is instructed to evaluate the evidence offered to them in the courtroom, determine the facts of a case, and then determine whether, based on these facts and the offered evidence ONLY, the defendant is, beyond reasonable doubt, "guilty" or not, of committing the crime with which he has been charged.
The American criminal justice system—and I speak here generally of courts at all levels—is built on the principle that only the evidence should be used to establish facts and guilt. And since data is often ambiguous, not leading to any specific conclusion without first interpreting, it is the duty of any defense attorney to introduce to the jury plausible alternative explanations of this ambiguous evidence. The jury is called to make up its own (collective) mind about the explanations offered by both sides.
Public defenders (like all defense attorneys), also have the duty of negotiating or arguing in their clients' best interest when he has been found guilty, and a (often unjust sentence is being considered. This is not optional; the judge deciding the case is free to make up her own mind about what the sentence will actually be. The defender merely offers an argument for why it should be a lighter sentence. Keep in mind, that on the other side of the room, there is another government employee, a Prosecutor, who is building his career on successful prosecution. The prosecutor, like the defender, has a job to do, and that job is to argue.
Public defenders have a somewhat undeserved reputation. Police officers are notorious for disliking defense attorneys because law enforcement officers tend to see defense attorneys as working against crime prevention in a well functioning justice system. The public at large too seems to believe that public defenders are up to no good, doing what they can to make sure crime rates stay high. The truth is, while some public defenders deserve their reputations as incompetent, many public defenders feel called to duty, and sacrifice potential personal financial gain so that they can offset the effects of zealous, dispassionate prosecutors. Some approach the matter from the perspective that poor criminals are as entitled to a good defense as rich criminals are. Without them, many defendants would be eaten alive.
The public defender does not work against the criminal justice system. He is in fact a part of it.
The above is not legal advice, and I, the author, am not a lawyer.