It seems intuitively true that anyone who invested in Moderna (MRNA 1.38%) in recent years made out like a bandit thanks to the company's quickly developed coronavirus jab. As it turns out, great businesses can sometimes be bad investments, at least temporarily. 

More importantly, past performance is no guarantee of future returns -- and star-studded stocks are no exception. So let's explore these concepts a bit further by figuring out how much a relatively small investment of $2,500 in Moderna a mere handful of years ago would have made you, and why the timing of your investment probably had a lot to do with how willing you were to hold on to it.

You'd be a lot richer

If you bought $2,500 worth of Moderna's shares at the start of January 2019, just a month after its initial public offering (IPO), you'd now have around $22,550 after experiencing ginormous gains of 801%. That's a pretty sweet investment, though there's a good chance you would have sold your shares in mid-2022 rather than holding on for longer, as that's when they were worth upwards of $75,000.

In case it wasn't obvious, the massive gains in the stock were powered by its development of a coronavirus vaccine using its technology, which subsequently went on to make $17.7 billion in revenue for 2021 and $19.2 billion in 2022.

But don't feel too bad for missing the opportunity in 2019; it was not at all an obvious investment to make. At the time, the company's debut on the market was panned as being overhyped, and shortly after its IPO, its shares crashed by 19% in a day as the market found the stock's price level. Many of the people who bought it in 2019 sat on steep losses for a while as its shares tumbled midyear.

What's more, in the years leading up to Moderna's IPO, it faced a lot of criticism for its poor and high-pressure work environment, its tight-lipped relationship with the scientific community, and the questionable safety characteristics of some of its pipeline programs. Despite working on its medicines for years, even at the start of 2020, its chances of long-term survival were questionable.

Now, those concerns seem antiquated. But at the time, they could have easily been enough to drive keen investors to dump their shares. In fact, for quite a while, it was possible to consider Moderna as being at a high risk of experiencing the same end as a business like Theranos. The similarities between the two were striking: tons of money raised, tons of hype, and a seemingly miraculous core technology platform that investors couldn't really evaluate in depth due to secrecy. 

Of course, Moderna's platform demonstrated its merits when the company rapidly developed and commercialized its coronavirus vaccine in 2020, and investors were able to keep track of its clinical filings to verify that the platform worked as claimed.

But hindsight is 20/20, and more importantly, hindsight doesn't boost your portfolio. So what might have happened if you made an investment after Moderna's value was proven to everyone? 

Investing later might not have worked out in your favor

As it turns out, if you invested in Moderna stock in May 2021, after its vaccine was approved and on the market for about six months, your shares would be down by 28%. But how could that possibly be, given that the company had yet to make its billions and billions from vaccine sales? Take a look at this chart:

MRNA Total Return Level Chart

MRNA Total Return Level data by YCharts

The lesson here is that the market values companies based on their expected future sales and earnings performance, in addition to a plethora of other factors. Everyone saw that Moderna was going to rake in plenty of cash from vaccine sales, so the stock went up in advance of that actually happening.

That process was made significantly easier than in a more usual (non-pandemic) situation because countries were scrambling to sign advance purchase agreements (APAs) for doses with the business for billions of dollars apiece, which it happily reported to investors. Then, once investors judged that peak sales growth was in the past, they redeployed their capital elsewhere, into other stocks where their money might grow faster. 

The way to invest in companies like Moderna is to buy their shares well in advance of their sales growth accelerating quarter over quarter, as by that time the market is liable to price in the growth and deprive investors of further gains. And if you're buying shares after a huge run-up, be ready to hold on to them for quite some years, as any slowdown in growth might leave you sitting on some hearty losses instead of impressive gains for a time. That's not to say the investment is now doomed, but investors must be willing to handle the risks and monitor any progression Moderna could make beyond COVID vaccines.