Historically it’s been a decent inflation hedge, and (effectively) a long-term forced-savings vehicle to many. But you’re right - rarely is it an “investment” in the true sense of the word.
buy it cheap. pay it off. live in it rent free. sell it at the height of the market. bank the money. buy cheap again.
play the housing market, invest wisely.
three last things... location. location. location.