In many high cost of living markets rent for a modest apartment is much cheaper than the cost of a mortgage on even the smallest house you can find.
For example, you can rent an apartment on the peninsula in the Bay Area for less than $3,000 a month, but buying the smallest house you can find on the peninsula will cost you at least $4,500 a month for just the mortgage.
If you rent in this case you can take the $1,500 in savings (plus the savings from no property tax, maintenance, homeowners insurance, etc.), and save/invest it.