A long-term look at the S&P 500 shows why more gains could be ahead