The Dow topped 40,000 for the first time, but the S&P 500 is thrashing the blue-chip index. Here’s why