Buy a house (with mortgage) for 4%. Inflation is 5% a year. Invest the money in real assets (literally anything diversified).
Your mortgage price goes down in future dollars because of the delta between interest rates and inflation.
Even if inflation isn't happening, mortgage rates tend to be fairly low risk, so any diversified bucket of assets has a historical return greater than the mortgage rate, especially over a 30 year period.
If you bought a 13% mortgage in 1984 (highest), in 30 years, S&P returns 11% by 2014, so even if you never refinance, during the highest interest rates you're only down 2%. If you refinance at basically any time in the 90s/00s you're way ahead.