The five-year test
Transaction costs to buy and later sell a home commonly total 8-10% of the value across both ends. Appreciation and principal paydown need time to overcome that. If you are confident you will stay five years or more, buying usually looks better. Under three years, renting usually does. In between, the details decide.
Compare total cost, not payment vs. rent
The honest comparison is rent against the full cost of owning: mortgage interest (not principal, which is savings), property taxes, insurance, maintenance, and any HOA dues, less tax benefits and any appreciation you assume. The rent vs buy calculator at /mortgage-calculator/rent-vs-buy/ runs exactly that comparison with your own figures.
What renting buys you
Mobility for career moves, no maintenance risk, and no exposure to a local downturn. If your work moves you every two years, renting is often the financially sound choice rather than the fallback.
What owning buys you
A principal-and-interest payment that stays fixed on a fixed-rate loan while rents move with the market, forced savings through principal paydown, exposure to appreciation on the full value rather than only your deposit, and control over the property.
Note that taxes, insurance, and HOA dues do rise over time even when the principal and interest do not, so the full housing payment is not fixed. Test a few appreciation and rent-growth assumptions rather than one. The answer often flips between reasonable inputs, and that tells you the decision is close.