The past five years have been rocky, to say the least. Investors have dealt with a worldwide pandemic, political tensions, trade wars, actual wars, economic troubles, market crashes, and more.

Throughout it all, broader equities performed well; the S&P 500 has grown 98% over the past five years. There's a good chance that the stock market will once again generate solid returns over the next five years.

Let's consider three excellent stocks to buy to ride this wave: Amazon (AMZN -0.28%), Shopify (SHOP -0.76%), and Eli Lilly (LLY -0.59%).

A person packs merchandise for shipping.

Image source: Getty Images.

1. Amazon

Amazon has been the biggest player in the e-commerce market in North America for years, but this dominance has come at a cost. The company invested a substantial amount in building its fulfillment network, which enables it to offer fast delivery on thousands of items, a key factor in its success.

Its e-commerce business carries low margins, but this could change based on recent technological advancements. The tech leader is betting on artificial intelligence (AI) and an army of robots to boost the efficiency of its shipping and delivery services. So although Amazon has been riding the e-commerce wave for two decades, increased productivity and the under-penetration of the market mean that it can still make significant progress on this front over the next five years.

Amazon's margins and bottom line should improve over time because of these changes. So should the company's highly profitable cloud business. Amazon Web Services (AWS) remains the leader in cloud computing, with faster-growing sales than the rest of the company.

The various AI services it offers are also improving results for AWS. Amazon CEO Andy Jassy believes the company is still in the early innings of the cloud and AI revolutions, while analysts' projections support the idea that e-commerce also has a long runway for growth. As these markets expand, Amazon should profit in the next five years and beyond.

2. Shopify

Shopify should be another beneficiary of the rapidly growing e-commerce industry. The company helps merchants create online stores, a task that can otherwise be expensive and time-consuming. But Shopify alleviates the headache by providing basic, highly customizable templates -- along with a range of services, from marketing to payments -- that allow business owners to focus on other aspects of their operations.

The company has found tremendous success. Its gross merchandise volume (it holds a 12% share of the U.S. e-commerce market by this metric) and revenue have historically grown rapidly, while free cash flow has improved significantly in recent years.

Since Shopify decided to abandon plans to build a fulfillment network that rivals Amazon's, its margins have also received a boost. Although it isn't yet consistently profitable, Shopify looks closer than ever to achieving that goal. It should reach it within the next five years, as revenue continues to maintain strong upward momentum. The stock has crushed the market this year; it can do the same through 2030.

3. Eli Lilly

Eli Lilly is currently the largest pharmaceutical stock by market cap. By 2030, it should also occupy the top spot by another metric: annual revenue. That's due to the company's diabetes and obesity medicines, Mounjaro and Zepbound, which share the same active ingredient, tirzepatide. Combined, they should generate more than $27 billion in sales this year. The list of drugs that have topped that total in a year is tiny, and most did so after more than a decade on the market, not just three years like tirzepatide.

Lilly is performing exceptionally well because of its work in weight management, and is expected to continue profiting from this area through the next five years. According to some projections, the weight loss market will be worth $150 billion by the early 2030s; it was valued at only about $14 billion in 2023. There's clearly strong demand for these medicines, and no company has a better portfolio -- or pipeline -- than Eli Lilly.

Next-gen GLP-1 candidates should help Lilly maintain its edge, at least for the foreseeable future. These include orforglipron, an oral medicine that performed pretty well in phase 3 studies, and retatrutide, which mimics the action of three different gut hormones (compared to two for Zepbound).

The drugmaker's revenue growth in recent quarters has more closely resembled a high-growth tech company's than a pharmaceutical giant's. Provided it maintains this trend, Eli Lilly is likely to generate strong returns over the next five years.