Tesla (TSLA 12.06%) has always gotten a lot of attention. Its groundbreaking electric vehicles have become icons of technological advancement, and the company that CEO Elon Musk helped build into the dominant player in its nascent industry has made shareholders extremely happy over the decade since its initial public offering (IPO).

But for index fund investors, Tesla just brought on the latest in a long line of controversies. That's because index funds just spent $90 billion buying Tesla shares -- and in just two short days, they've already lost $7.4 billion for their fund shareholders.

Person with hands on head looking at stock chart with a lot of red.

Image source: Getty Images.

Buying at an all-time high

Index funds knew for more than a month that Tesla stock was about to become a hot commodity. It was in mid-November that S&P Dow Jones announced that Tesla would join the S&P 500 Index, effective as of the beginning of trading on Dec. 21.

That meant that index funds had to target buying shares as close to the end of the day on Dec. 18 as possible. That way, their returns would match up with the S&P 500's returns.

However, unlike the index -- which has the virtue of not having to actually implement its investing strategy of holding its roughly 500 constituent stocks -- the funds had to figure out how to do all that buying while disrupting markets as little as possible. That was a tall order, because Tesla's market capitalization of more than $600 billion meant that the electric automaker would represent a sizable percentage of a massive multitrillion-dollar market.

In the end, index funds paid roughly $90 billion in Tesla shares, according to S&P Dow Jones Indices analyst Howard Silverblatt. And as you can see in the chart below, the $695 per-share close for Tesla's stock on Friday afternoon was the absolute top-dollar price those funds could've paid.

TSLA Chart

That spike higher is the price index fund investors effectively paid. Data source: TSLA data by YCharts.

A $7.4 billion hit

On Tuesday afternoon, Tesla's shares were trading at around $638 per share. That marked a second straight day of losses that added up to more than 8%. The $90 billion in stock that index funds bought late Friday was already worth $7.4 billion less than it had been just two days before.

As you can see above, the drop from the highs looks very much like the mirror image of Tesla's ascent immediately before the index change took effect. The impact of index funds' forced buying is evident from how the stock rose and fell surrounding the event.

Funds could've done better

The worst part is that index funds didn't have to take this financial hit. To put the stock's moves into a slightly wider perspective, Tesla shares traded just over $400 immediately before the S&P Dow Jones Indices announcement. It took less than three days for the stock price to top $500 per share, and by the end of November, Tesla had climbed above $600 per share.

That's roughly where Tesla's share price stayed for the following couple of weeks. Yet in the final run-up to the index inclusion, Tesla made one more push upward. The last-minute spike didn't quite make it to the $700 level, and it was so brief that it doesn't even show up on many intraday stock charts. But it was nevertheless the official final figure from which S&P 500 performance will get calculated going forward.

Why index funds don't care about you

The problem with index funds is that they have absolutely no incentive to avoid the gamesmanship that inevitably leads to losses like this. Most of the time, companies are much smaller when they get added to the S&P 500, so the negative impact on shareholders isn't as large as it was here. Nevertheless, it happens to a lesser degree every single time a new stock joins the index.

Investors choose index funds solely to track indexes. When indexes create discontinuities like this, fund managers blindly follow the rules, to their shareholders' detriment.

Now everyone's rooting for Tesla

Of course, given Tesla's past performance, it's certainly possible that the stock will climb to $700 and beyond in the future. It could even happen today or before 2020 ends. If that happens, then all will likely be forgiven. And now that Tesla's part of the index, it's what every index fund investor wants to see happen.

Yet as helpful as index funds are for ordinary investors, this is the unseen price that index fund shareholders pay. In Tesla's case, it took $7.4 billion out of their hands and put it into the hands of those who weren't constrained by hard-and-fast investing rules.