That is simply not true. Even if you bought at the peak in 2007 in Sunnyvale you are likely up 50% or more on your investment. If you were lucky and bought in 2005 or 2009 your house is probably worth 60-70% more than when you bought it. This has been true for the past 25-30 years in much of SV. That doesn't mean it will continue forever, of course, but the trend has been there for a very long time now.
Ok, but what if I had invested the house money - would the rate of return be more/equal/less? There's of course the economy crash but I would expect that to affect house prices too. Just sounds like a bad idea to consider primary residence an investment.
It's surprisingly hard to beat investing in real estate in growth markets like SV because of the leverage afforded by the ratio of down payment to home price....
For example in Los Gatos, appreciation has been 5% on average for many years, and so the 200k you put down on a 1m house will typically appreciate by 50k. 25% roi in year 1, increasing each year. Of course, property appreciation doesn't happen in a straight line, and houses cost money to maintain (property taxes, etc) but the larger point is valid.
Obviously that depends on what you invest in and how much risk you are willing to carry. In the long term the stock market index funds have returned about 6-7% annually adjusted for inflation. Take almost any 10-year window in the past 30 years and SV home prices have either matched or beaten that substantially.