Comparing "mortgage payment" to "rent" misses most of the real cost on both sides. Buying tallies the down payment, closing costs, every mortgage payment, property tax, insurance and maintenance over the horizon — then subtracts the equity actually built (home value minus remaining loan balance, minus selling costs) to get a net cost. Renting tallies total rent paid — but credits the renter with investing the money a buyer would have tied up in a down payment and closing costs, growing at a market return, and subtracts that investment balance from total rent paid. Whichever net cost is lower is the better deal for the assumptions entered — this is a genuinely assumption-sensitive comparison, not a fixed answer.
A $400,000 home, 20% down, 6.5% mortgage, against $2,200 rent with the down payment invested at 7%: renting is the cheaper net position through year 15 (rent net cost $229k vs buy's $253k), but buying overtakes it by year 20 ($276k vs $338k) as accumulated home equity and appreciation compound past the ongoing cost of rising rent.
Buying has large upfront costs (down payment, closing costs) and selling costs at the end — over a short horizon, those fixed costs aren't amortized over enough years to be beaten by the relatively slow, compounding advantage of home equity and appreciation.
It's crediting the renter with what the down payment would have earned elsewhere — a higher assumed return makes renting look better since that opportunity cost of a buyer's tied-up cash grows faster; a lower one narrows or eliminates renting's advantage.
Only if you ignore what the money not spent on a down payment, closing costs, property tax, insurance and maintenance could otherwise be doing — a renter who actually invests that difference isn't losing it, they're compounding it elsewhere instead of in home equity.
Mortgage interest tax deductions, rent control or lease-renewal uncertainty, the value of not having a landlord, moving costs, and any change in interest rates or home prices beyond a single steady assumption — all real factors this simplified comparison doesn't capture.