It's rules and legislation. The job of banging together reasonably serviceable form of shelter isn't that expensive. It's only expensive if you have to jump through a lot of hoops to use certified designs, materials, etc. deal with inspections, use expensive people for that have had training for wiring things together, etc.
Any slum in developing nations features lots of housing that people bang together out of trash. Very unsafe. But it works. We've been creating shelters for ourselves since prehistory. It's not that hard.
Millions of people live in slums. Upgrading that kind of housing to something slightly better isn't all that hard. Most people that a are a bit skilled can bang together a shed in their garden in no time at all. Putting a few solar panels on top isn't that hard either. And you can plug them into batteries easily. You can buy that kit on Amazon and run your power tools of that. All legal.
It's only when you want that in your house connected to the grid that cost suddenly balloons from a few thousand to many tens of thousands. Exact same technology. Maybe you'll use slightly more panels and a bit bigger battery. But now it's a lot of gate keeping by inspectors, electricians, certified equipment, etc. that come into play.
Same with houses. You can buy a recreational vehicle or caravan for a reasonable amount of money. Second hand these are very affordable. And some RVs can be quite nice to live in and even have AC. So, why are houses so expensive relative to RVs? Prefab housing has been a thing for decades. If you remove the wheels from an RV, it's basically a house. If you live in an RV, you are referred to as trailer trash. It has a stigma. But it's very cheap. Poor people do that. Because it's very affordable housing. That's why it's a popular option for people that would otherwise build slums.
> The job of banging together reasonably serviceable form of shelter isn't that expensive. It's only expensive if you have to jump through a lot of hoops to use certified designs, materials, etc. deal with inspections, use expensive people for that have had training for wiring things together, etc.
"Reasonably serviceable" — ay, there's the rub!
The U.S. Navy's nuclear propulsion program has a saying: You get what you INspect, not what you EXpect. Certifications, inspections, etc., are meant to try to keep lazy-, sloppy-, and/or dishonest providers from passing off shoddy (or even unacceptable) work product.
In many areas, most customers don't have — and shouldn't have to have — the expertise or the time needed to inspect and assess providers' work product. By requiring knowledgeable inspections in critical areas, we increase the cost a bit, but we improve safety for everyone — which lets us non-experts spend our time more usefully. (It's a form of division of labor.)
To be sure: Certifications, etc., can be captured by industry groups and used to limit competition and increase prices. That's a separate issue, one that can be dealt with in other ways.
Quality — and quality assurance — aren't free.