You need to compare money paid for mortgage minus price of house against money paid for rent (when you're left with no assets after all the years of paying it).
NYTimes has a great calculator for doing just that https://www.nytimes.com/interactive/2024/upshot/buy-rent-cal...
NYTimes has a great calculator for doing just that https://www.nytimes.com/interactive/2024/upshot/buy-rent-cal...