There's plenty of lawyers out there - but, like in programming, there are a lot fewer good ones. In general, people are willing to pay $500 / hour because they can't find one of similar quality for a lower price.
We still find people representing themselves because they can't "scrape together a retainer". They're not trying to hire $500/hour guys. They'd hire anyone that'd take their case for what they had. The law has become so twisted that its genuinely long, hard work just to get a case together and get in the door. There's a minimum barrier to entry that the average joe just can't meet and the most inexpensive of lawyers can't make a living doing. The work is too much and the people have too little. Its not the lawyers. The whole system is failing. Its just failing from the bottom up. Its only just now effecting the $500/hour level.
If a few poor people here and there end up representing themselves its no big deal. They just operate at a huge disadvantage and get screwed. If most people are forced to represent themselves or go with an overworked public defender the whole system will crack into to very distinct parts.
There's a lot of disagreement around "scope" - some people are actually opposed to almost any restriction of practice, even in areas like medicine and law. Other people want to see similar associations/cartels (depending on your point of view) set up for software development. There's also a big middle ground, people who do see a justification for credentialing and licensing in some cases, but who think that the scope of what requires a license has expanded far beyond what was reasonable and needed to protect the public. I tend to fall in the middle group, but with a high degree of suspicion of cartels.
There's also some funny business on the demand side for law. America's truly byzantine tax code, for instance, provides lots of employment for $500/hr lawyers. Imagine if programmers could mandate that all code had to be written in the most bloated enterprise java possible, and had to be written by people with three year graduate degrees from programs largely inaccessible to international students. This would include many tasks that could otherwise have been handled by smart people with no degree who read the book. Anyone who didn't comply could be prevented by legal force from practicing, or even sent to prison. Now you'd have something comparable to the legal profession.
In the end, law firms tend to trade on longstanding reputation, which is a fine, but imperfect, way of handling this problem. These days, there is no reason to assume that high rates == quality, or vice versa.
The market will sort this out eventually: right now clients are making pricing demands on big law firms that are cutting their margins significantly. As a result, firms are ditching costs in a kind of emergency sale. My own opinion is that many firms are gutting their best assets (their new, young lawyers) in order to preserve the partner profits, and that will be their downfall. Meanwhile, the next generation of lawyers will be free to charge much less, and will actually make more money.
Code and the law kind of do the same thing (which is why we use the same word for it) but the platforms are vastly different.
There's plenty of lawyers out there - but, like in programming, there are a lot fewer good ones. In general, people are willing to pay $500 / hour because they can't find one of similar quality for a lower price.