When we bought our first house, our mortgage was more than rent. But within two years, it was less - rent kept going up, and our mortgage didn't.
Um, I guess I should back up a step. I'm assuming that you have to live somewhere. So the choice (for most of us) is between buying and renting, not between dropping $500,000 on a house and investing $500,000 in the stock market. Our choice is actually whether to drop, say, $50,000 on a down payment and take on a mortgage, or drop $50,000 in the stock market and keep on renting.
So to me, buying a house that I live in is a way of buying back the rent money. Yes, I pay interest on it. Yes, I also have to do maintenance and pay property tax. But when I rent, that money is gone. Whereas if I buy, that money is still gone as far as my budget is concerned, but after 30 years I own the house.
Now inflation enters the picture. I payed $50,000 down for a house that was worth $500,000, instead of dropping it in the stock market. Now, say, 10% of inflation happens. In the stock market, I would now own stocks worth $60,000. But instead, I own a house worth $600,000 (with a $450,000 mortgage). So the mortgage let me reap the gains of inflation on money that I borrowed.