How closely have you looked at those $40K houses? I've seen a handful of sub-$100K smaller houses listed in my region, but they're wrecks; they'd need a massive amount of work to get anywhere near the comfort and safety level of a modern, well-maintained house. They're basically the house equivalent of buying a $500 car.
> 1000 sq ft houses that sell for $40k > because nobody wants a house that small
a 1000sqft house in Palo Alto would sell for >$400K just for the land. It would be a "teardowns", and a $40 house+lot would be converted to a $300k 2600 sqft houses -- quite reasonable, so the explanation lies elsewhere (access to employment, entertainment, educations?)
Sure, but a $40k house will need anywhere from $90k to $160k worth of additional repairs to be safe to inhabit.
And since that cost isn't in the equity, most people in most areas can't qualify to finance that. (A $200k mortgage is not identical to a $40k mortgage and $160k reno loan).