Trying to outperform the stock market is not an easy task. Warren Buffett, one of the greatest investors of all time, even suggests that for most people, simply buying index funds is the best path when it comes to their portfolios. But for some, this just won't cut it. 

Here are three stocks that have handily beaten the S&P 500 over the trailing five-year period, and they have the chance to do so again in the future. Spreading out a $5,000 investment equally among these businesses (as part of a well-diversified portfolio) would be a worthwhile financial move. 

Two people working on a renovation project.

Image source: Getty Images.

Lowe's 

Lowe's (LOW 0.43%) is a major force in the massive home-improvement market with fiscal 2021 sales and net income of $96.3 billion and $8.4 billion, respectively. The business was a huge beneficiary of the pandemic as consumers, spending more time at home, turned to renovation projects. And in stark contrast to the beginning of the pandemic when do-it-yourself business surged, lately it's been Lowe's professional sales that have shown strength. 

Pro revenue increased 24% in the latest quarter. These customers are critical to Lowe's because they tend to visit stores frequently and spend more, which can boost the gross margin (33.3% in fiscal 2021) and operating margin (12.6% in fiscal 2021) over time. Moving the Lowe's 4 Pros site to the cloud has improved functionality and allowed for personalized offers, helping to spur demand. 

The strong housing market helps Lowe's because consumers are more inclined to invest in their homes when prices are rising. With a short housing supply in the U.S., expect this trend to continue, supporting the company's prospects in the years ahead. 

As of March 22, Lowe's stock sells for a price-to-earnings (P/E) ratio of only 19, which is less than larger rival Home Depot's ratio of 21. Investors get a business that has steadily increased profit in recent years, and that also has valuation upside if it can continue executing going forward. 

Lululemon 

As a burgeoning player in the athletic apparel market, Lululemon (LULU 2.64%) has been registering impressive top- and bottom-line growth over the years. The popular consumer brand, which posted outstanding same-store sales growth of 27% in its fiscal 2021 third quarter (ended Oct. 31), has successfully transitioned from being primarily a seller of women's yoga pants to now offering all genders high-quality performance clothing. 

What makes Lululemon special is just how strong its brand is. Its gross margin in the most recent quarter was 57.2%, demonstrating customers' willingness to pay up for premium merchandise. This helps explain why the company's gross margin has held relatively steady in the inflationary environment. Furthermore, generating 40.4% of revenue from the direct-to-consumer channel supports pricing power. 

Like many businesses today, successfully navigating congested supply chains is a focal point. Lululemon is not immune, and management is forecasting fourth-quarter revenue to come in at the low end of guidance, near $2.1 billion. This would still represent nearly 23% year-over-year sales growth. And thanks to the fading effect of the omicron variant, consumers might now be more inclined to shop at Lululemon's 552 (and counting) worldwide stores.  

Lululemon shares are down 20% in 2022, providing opportunistic investors with a chance to buy the stock on market weakness. The brand is powerful, financials are superb, and there's a ton of growth for the business, particularly in international markets.  

O'Reilly Automotive 

Automotive aftermarket parts retailer O'Reilly Automotive (ORLY 0.05%) easily makes this list because of its steady and predictable business model. People need functioning automobiles to make it through their days, and with 5,759 stores in the U.S., O'Reilly is there to help. 

Over the past five years, the company has increased revenue 56% and net income by 109%. In 2021, the gross margin of 52.7% and operating margin of 22% were both higher than the prior year. And because O'Reilly produces a ton of free cash flow, it is able to return capital back to shareholders in the form of stock buybacks. Just last year, management executed $2.5 billion in share repurchases, a trend that will likely continue in the years ahead.  

Investors are starting to worry that the Federal Reserve might hike interest rates too aggressively this year in order to fight inflation, which has the potential to cause a recession. Not only does O'Reilly do well in a strong economy, when consumers tend to drive more and increase the wear and tear on their vehicles, but it also flourishes in an economic downturn. People will put off buying new vehicles and instead invest in repairs and maintenance to keep their existing cars running longer. This situation undoubtedly helps O'Reilly. 

Whichever path the future brings, investing in O'Reilly today looks like a safe bet.