> the Kowloon Walled City
Where would the people who lived in Kowloon Walled City have lived instead, had it not existed? That's the question. Four drafty walls and a roof that sometimes leaks is better than none.
> building code didn't exist and the outcome wasn't a magical utopia for lower income housing
Well, yes, a magical utopia isn't going to exist no matter what we do.
> those levers should not include letting people build sketchy shacks piled up on top of each other
In the US, building codes mandates a floor in building quality (and therefore the price) that goes far, far beyond "sketchy shacks", and zoning in large parts of the country simply forbids high-density (and therefore more cost-effective) residences.
As a concrete example of the former, the 2020 National Electrical Code mandated that outdoor HVAC units (e.g. the condenser that sits outside of the house) be protected by ground-fault circuit interrupters. This turned out to hopelessly front-run market reality, because existing GFCI breakers caused nuisance trips all the time when applied to HVAC equipment; so much so that the NFPA walked it back and issued an exemption to this rule until late 2026, when hopefully better breakers can be on the market. But in the meantime, this caused additional expense, delays, and uncertainty in homebuilding. This is just one minor example out of countless additions to the various building codes in recent years.
Of course, the people who write such codes like to say that "every line is written in blood". But remember, making something safe, like anything else, doesn't come without a cost. There is no free lunch, and everything is a tradeoff. We can build an amazingly well-insulated, net-zero house that is very comfortable to live in, has no VOCs, will never cause an electric shock to an occupant, will not catch fire, etc. for $5,000 a square foot; but approximately nobody will be able to afford such a house.
> The government as a whole has many levers it can, should, and does pull
Often times they're not levers, they're ratchets ;-)