Two years ago, Tesla (TSLA -3.40%) was one of the hottest stocks in the market. Its business was becoming increasingly profitable, and its stock was about to post one of the best years on record for any large-cap company. Moreover, the automaker got an invitation to join the S&P 500 (^GSPC 0.87%) index, adding to share gains as shareholders anticipated that index funds would be forced buyers of the stock at any price.

Fast-forward to today, and the late-2020 addition of Tesla to the S&P 500 has been costly for index fund investors. The electric vehicle (EV) pioneer's stock has not only given up big gains from 2021 but is now down significantly from its levels two years ago, even as the S&P has managed to post a positive return over the same time period.

Strength in year 1 gives way to weakness in year 2

S&P Dow Jones Indices gave index funds plenty of warning that they were going to add Tesla to their most influential index. More than a month passed between the time of the initial announcement of Tesla addition and the Dec. 21 effective date on which Tesla's stock price had a direct impact on the S&P 500. S&P analysts projected that in order to match Tesla's weighting within the index, index funds would have to pay about $90 billion to obtain shares. Many of them paid prices close to the split-adjusted $232 share price at the close of business on the preceding Friday, Dec. 18.

In the first year of Tesla's membership in the S&P, the auto stock was volatile, but it managed to keep participating in the bull market and outperform the index. As of early January 2022, Tesla shares were up nearly 70% from where they entered the index, compared with just a 30% rise for the S&P 500.

TSLA Total Return Level Chart

TSLA Total Return Level data by YCharts.

2022 hasn't been nearly as kind. Not only has Tesla given up all those gains, but it has continued to fall below the price that index fund investors paid for their shares when the stock got added to the S&P 500. Tesla stock recently traded below $170 per share, a 27% drop from the entry price for index investors and dramatically underperforming the 10% total return that investing in the entire S&P 500 has produced over that time frame. That amounts to a roughly $24 billion hit to index fund returns tied to Tesla's swoon.

The cost of index front-running

The biggest part of the problem stemmed from the forced nature of index fund buying. Immediately before the mid-November index announcement, investors could have bought Tesla stock for around $135 per share on a split-adjusted basis. Yet over the course of the month, that price moved sharply higher, stabilizing above $200 per share until a last-minute surge took it still higher.

Admittedly, Tesla was a special case, because its market capitalization had grown so large before it received its invitation to join the S&P 500. That doesn't often happen, but here it stemmed from certain qualification criteria that took a while for Tesla to meet. Yet even when companies are smaller, the same phenomenon usually occurs, just with a less dramatic financial impact on index fund investors.

No choice for index fund investors

Index investing is a great way to participate in the stock market's long-term gains, and its lack of active trading makes it possible for index funds to have rock-bottom fee structures. However, the mindless devotion that index funds have to tracking their target indexes comes at the cost of introducing artificial stock price moves when constituent stocks get added, and often, funds pay more than they otherwise would have to for their shares.

In the long run, it's certainly possible that Tesla stock will rebound from its current levels and begin to outperform the S&P 500 once again. Yet at least for now, index investors aren't too happy to have missed out on Tesla's best years only to buy at what proved to be an inopportune moment for the EV stock.