The above is the rule of thumb though. You have to run numbers for your life situation as they constantly change. Note that some of the numbers are for your life situation which itself can change. Renting is often better just if you buy and have to move there is a bunch of negatives.
Owning a home, I'm investing the difference I save by not having to rent. Difficult to see how a renter can come ahead unless the time horizon is just a couple years.
Rents only ever (mostly) go up. Mortgages only go down (refinances). Those lines can cross in just a few years into ownership. By now, renting the same house I own is about 4x more expensive.
One thing you really don't want when going into retirement is a constantly and unpredictably increasing housing cost when you'll be on a fixed income.
As a simple example, my fully-laden (mortgage + insurance + tax) cost on a 2600 sqft 4br/3.5ba house on a 1/2 acre lot in a nice suburb in San Antonio purchased in 2012 was around $1400/mo compared to this being the typical rent for a 1br apartment pre-2020 in San Antonio anywhere that wasn't in the ghetto. That was largely thanks to having a 2.4% interest mortgage and being able to buy in 2012 in the dip for property values. The same property that was purchased for $162k in 2012 sold for $340k in 2022, and the mortgage rate for the new buyer was around 6.5%, doubling both price and interest rate greatly changes the equation, but let's not act as if that hasn't been a relatively recent (pandemic-tied) shift.