Sure, buying real estate is seen as an investment, but it's also a spot to live and to keep all stuff to help or hedge your enjoyment of life.
Some people just want to live, debt free, and be left alone.
If I ever have to leave my doomed home with only what I can carry, I'd rather owe as much as possible at that point in time. I think that debt owed to human beings is strictly better than the same amount of equity just vaporized with no possible recourse.
Let's say you owe 100000 EUR for a 200000 EUR house, pay 2% interest, inflation rate of 10%. Your net worth is 100000 EUR in the first year.
If you repay 8000 EUR, the next year you owe 92000+2%*92000=93840 EUR and your net worth is 220000-93840= 126160 EUR.
If you repay 4000 EUR and invest 4000 EUR in gold, next year you owe 100000-4000+2%*96000=97920 EUR, your gold is worth 4400 EUR after inflation and your net worth 220000-97920+4400=126480 EUR. Plus you have improved liquidity.
If the inflation rate is higher than the interest of your loan, it's often better to invest in inflation-proof assets.