Did you account for the fact that equity gains in real estate for primary residences in the US are tax free? Your equities, even long-term, are taxed at a non-zero rate.
Just to clarify the capital gains you have on the sale of your primary residence isn't tax free. You get the first $250k free for an individual and more for a married couple. This is very generous and better than you get for equity investments for sure, but once your gain exceeds those amounts it is taxed at normal capital gains tax rates.