House prices do not go up. Land prices in countries with growing economies tend to go up. The price of the house on the land generally depreciates as it wears out.
Houses require money; they are called money pits for a reason. You have to replace HVAC periodically, roofs, repairs, rot, foundation problems, leaks, electrical repair; and all of that just reduces the rate at which the house (not the land) loses value.
To maintain value (of the house proper), you need to regularly rebuild parts of the house. People expect different things in Kitchens, bathrooms, dining rooms, doors, bedrooms today than they do in the past, and wear on flooring and fixtures accumulate over time.
The price of land and is going to be highly determined by the current interest rates. Interest rates are currently near zero; if they go up by even a few percent, we can expect land prices to stop growing and start shrinking, even if the economy continues to grow. So the assumption that land+house prices go up is predicated on the last 35 years of constant rigorous economic growth mixed with interest rate decreases. This is a common illusion, that people assume the recent economic past is somehow the way things are "naturally". But we cannot decrease interest rates further, and rigorous economic growth is far from guaranteed.
This is because people price land based on their carrying cost; the cost you have to spend out of your income to have ownership of it. And that is a function of interest rates. Throw in no longer expecting land values to constantly grow and second-order effects that boost land value also go away.
Depending on the juristiction, a mortgage is a hugely leveraged investment. It is akin to taking 10,000$, borrowing 40,000$ and buying stock. If the stock goes up, you make almost 5x as much money; if it goes down, you lose 5x as much. And you owe a constant stream of money to service the debt on top of that.
If you want to be risk free, work out how you'd deal with the value of your house dropping by 50% together with losing your job, getting a job paying half as much after a period of 6 months unemployment. The new job requires a 1.5 hour commute from your house. Interest rates going up to 12% and your mortgage is up for renewal (in 15 years - they climbed gradually over the time, say), optionally.
That is a medium-bad situation (not a great depression scale problem), but is a realistic "bad luck" event that could happen to you. Not likely, but possible.
Can you weather it? If so, the risk is within your bounds. Note that going bankrupt may be a reasonable plan to such a bit of bad luck. However, note that had you not purchased the house, you wouldn't be bankrupt in that situation.
It is reasonably likely that house prices will, after you spend ~3% of the construction cost of the house per year, pay the mortgage on the land+house, grow at a rate sufficient to offset the cost of renting and generate an economically reasonable level of profit. It is not a risk-free investment.
If someone tries to sell you a risk-free investment, they are almost certainly wrong.