A lot of people are unable to afford a public defender, so I was wondering if this is possible.
The short answer to your question is: yes, but you shouldn't if you can possibly avoid it.
You didn't specify which jurisdiction's law you were curious about, so in some jurisdictions (especially civil law jurisdictions, such as continental Europe), the the answer may be different. But under the law as it exists in most U.S. jurisdictions, a natural person may act for himself or herself in most legal proceedings; this is known as appearing "pro se," for oneself. (Corporations may not appear pro se in U.S. courts.)
However, while the court will grant pro se litigants a lot of leeway, the pro se litigant is still bound by the same rules of law that bind an attorney. In practical terms, for anything more complex than small claims court, this means appearing pro se is a terrible idea.
Think of it this way. There's nothing stopping you from performing your own vasectomy at home, either--but you shouldn't be surprised if the results aren't as satisfactory as when someone does it who went to med school and studied anatomy.
The analogy works in another sense, too. I've seen many people bring or defend lawsuits pro se because every lawyer they went to refused to make the improper/false/nutty/frivolous arguments they wanted made. In other words: sometimes a lawyer's best contribution to your case is some much-needed perspective. That's one reason most lawyers would never dream of appearing pro se if their own necks were on the line.
The UK does have free lawyers for those who cannot afford an attorney. In fact, it is even more liberal than the US, including representation in civil cases for the most part as well (there are a few exceptions, like libel, and from what I've read, even that is changing).
Rather than the main source of free representation being called public defenders, they are referred to as Legal Aid, which is a government funded agency much like public defenders are in the United States.
Article 47 of the Charter of Fundamental Rights of the European Union provides that legal aid will be made available to those who lack sufficient resources, in so far as such aid is necessary to ensure effective access to justice.
In the event legal aid is too busy to accept a new client, the court will appoint a solicitor from a list of private firms/practitioners that will act in the same capacity.
Article 6 of the European Convention on Human Rights (ECHR) guarantees the right to a fair trial in both civil and criminal proceedings. This has been interpreted as providing for a general requirement of some measure of “equality of arms” between the state and the individual or between the parties in the case, and the overall structure of the article, as well as the case law of the Court, stresses the vital connection between the right to legal assistance and the general interest in guaranteeing the right to a fair trial.
When faced with a criminal charge, the right to legal assistance is explicitly set out in Article 6 (3) (c). An entitlement to free legal aid in civil cases is available in cases where the absence of legal support would make any equality of arms impossible and would effectively deprive an applicant of access to the proceedings as such, for example, when a case can be filed to a court only if assisted by a lawyer in circumstances when an applicant cannot clearly afford one.
My guess is, if your friend was denied counsel under legal aid, she has too much income or to many assets to qualify, or she is involved in a case that does not qualify. That said, the right to counsel in in the UK is a right for the indigent in most types of cases (even civil) and is becoming more and more fundamental as imposed by findings of the European Court of Human Rights Jurisprudence.
Here is a link where you can at least begin to get some information.
In the United States, a public defender is a right guaranteed by the 6th Amendment in criminal prosecutions. The right to a public defender is not guaranteed in civil trials.
"In all criminal prosecutions, the accused shall enjoy the right to a speedy and public trial, by an impartial jury of the state and district wherein the crime shall have been committed, which district shall have been previously ascertained by law, and to be informed of the nature and cause of the accusation; to be confronted with the witnesses against him; to have compulsory process for obtaining witnesses in his favor, and to have the assistance of counsel for his defense." - Sixth Amendment of the U.S. Constitution.
You should probably watch this video, to fully appraise yourself of the status of public defenders in the US legal system.
Theoretically you are guaranteed a public defender by the government for free, but in practice you can be charged. Different states use different methods to do that.
Also, public defenders are overloaded with work. They might not be able to give enough time to your case either because they are underfunded and cannot afford a staff or because they might not have an office to work from.
In some states you will have difficulty getting one.
Please watch the video mentioned above for more references and the method of research.
I agree with @chapka's answer.
However, I would just ask you to re-consider the premise of your question:
[...] unable to afford a public defender [...]
Public defenders only work criminal cases. If you have been arrested and charged with a crime, you are entitled to have the court pay the fees of your attorney.
In civil court in the US, a pro-se litigant is a second-class citizen within the court, compared to the other side's attorney, who is considered an "officer of the court."
That basically means that anything coming out of THEIR mouth is considered true unless proven otherwise, and everything coming out of YOUR mouth is considered false unless proven otherwise.
So, it's not a good idea, if there is any other option.
"A lot of people are unable to afford a public defender[.]"
Your question is based upon a false premise. It is wrong by definition.
The only reason you are ever entitled to a public defender (a right limited to criminal cases and termination of parental rights cases), is when you cannot afford an attorney. It is impossible to be "unable to afford a public defender." You can only be too affluent to be eligible for a public defender.
If you can afford a criminal defense attorney but would rather not spend the money (perhaps because you think it would be futile to do so) you may represent yourself in court instead.
In cases other than criminal cases and termination of parental rights cases, e.g. evictions, child custody cases, divorce cases, collection lawsuits, property disputes, foreclosures, bankruptcies, immigration cases, etc. You do not have a right to attorney and must represent yourself if you can't afford to hire an attorney.
Someone who represents themselves is called a pro se party. In some kinds of cases, such as evictions, collection lawsuits, foreclosures, child custody cases and divorce cases, most defendants are pro se.
Usually, pro se parties make stupid mistakes related to technicalities in a lawsuit and are severely prejudiced as a result, but pro se parties don't always lose, particularly when the other party is also pro se.
As an experienced pro se plaintiff with currently two cases pending review in the U.S. Supreme Court (see here and here), I strongly recommend litigating in pro per, provided that (1) one engages in a steep learning curve, (2) is diligent, and (3) is able to cope with the dishonorable acts that many judges and opposing counsels commit on a regular basis.
Judicial corruption is an unfortunate reality (example: Michigan courts), and I am sure that very few attorneys would have handled my cases with diligence and competence. Even if an attorney is honest and forthcoming, the fact that his law office handles several cases simultaneously tends to impair their ability to capture subtle aspects of one's own case. Moreover, I've seen attorneys lose cases because they make novice's mistakes (for example, by filing a lawsuit without doing the prerequisite exhaustion of administrative remedies).
If more people litigated in pro per, more cases would be decided on the merits than by influence trafficking, and there would be greater awareness about judges who are unfit for judicial office.
-- Edited to add references in response to ohwilleke's comment: