The solution is to spread out from concentrated megacities. Overcrowding happens in cycles historically, and every time it happens it's bad for human health and the health of human society.
Everyone wants the space of a single family home and the slew of "modern amenities" a city offers, while lamenting they can't afford it. Our parents and their parents lived in far out areas that were cheap / semirural at time of purchase and matured to very nice places to live over decades of hard work put in by the local community. Of course those well-built-up areas are expensive, and of course the people that created those communities don't want to see them completely changed by density. We just need to build more opportunities like these, and people need to be willing to sacrifice on location at the start to see the area build up around them over time.