This can be true, but the math is complicated - it depends on the differential between a mortgage payment and what rent in the area would be, as well as expected maintenance costs.
If you assume a mortgage runs 3% (which seems to be approximately correct this month in Canada), housing appreciates 5%/year, we're looking at a 500k house over 25 years, and you can invest cash at 8%:
- Annual mortgage is 28,395, or 2,366/mo
- Total mortgage payments are 710k
- Home value is 1,693k
- ROI is 983k
- Matching that ROI at 8% needs almost exactly $1510/mo
- So naively you'd need to find rent at $856/mo to come out ahead renting
- But now adjust for property taxes and maintenance (over 25 years you probably need a new roof, maybe new siding, furnace, hot water tank...). Like I said, it gets complicated.
The other reason people buy homes is stability and control - you can't be evicted from a home you own other than for non-payment (no risk of the landlord wanting to move in), and you also have the freedom to renovate to suit your changing needs.