The stock market has largely shaken off the historically steep declines that made headlines earlier this year. The Dow Jones Industrial Average is only down 6%, the S&P 500 is sitting near breakeven, and the NASDAQ is up about 17% year to date.

While it's unclear what will happen on Wall Street in the near future, one fact is indisputable: Investing in high-quality stocks remains the surest way to build wealth over the long term.

Assuming you have sufficient emergency funds to fall back on and $4,000 (or less) that you don't expect to need over the coming three to five years, here are four stocks you could invest in that will stand the test of time and could make you rich in the coming decade -- even in the face of the continuing uncertainty caused by the COVID-19 pandemic.

A sheet of $100 bills rolling off a printing press.

Image source: Getty Images.

1. Facebook: Staying connected in the stay-at-home era

With new coronavirus diagnoses surging to record levels across this country (and in others), many people continue to hunker down at home, venturing out only occasionally for the essentials or to break up the monotony. But that's not changing their desire to stay in touch with family and friends, and one of the biggest beneficiaries of that need to feel connected will continue to be Facebook (META -10.56%).

Every month, 2.6 billion people log into the social media platform, and more than 1.7 billion use it daily. The unmatched network effect created by that vast system of users gives Facebook unparalleled advantages in its space. Another important data point is that despite scandals and the growing threat of regulatory intervention, Facebook shares been remarkably resilient to external factors, gaining more than 57% in 2019. 

Facebook's reach also extends far beyond its namesake platform, with Instagram, WhatsApp, and Messenger filling out its family of services. Nearly 3 billion people use at least one of those apps every month and more 2.3 billion log in daily. And as the pandemic struck, user engagement naturally increased.

It's also important to remember that the company still has a couple of large untapped revenue opportunities. Ads are commonplace on Facebook and slightly less so on Instagram, but the company has only just begun to mine the vast potential for advertising that exists on WhatsApp or Messenger. Monetizing them offers Facebook an avenue for years of lucrative growth.

A person holding a smartphone near a touchless digital payment terminal

Image source: Getty Images.

2. PayPal: Helping make digital payments the standard

One of the trends that got a significant boost as a result of the pandemic was the shift toward digital payments. This was partially the result of increased adoption of e-commerce, but it was also due to the pressing desire for touchless payments as people and businesses looked for ways to reduce the chances of customer interactions spreading the coronavirus. No fintech company is better positioned to benefit from that ongoing change in consumer behavior than PayPal (PYPL -1.14%).

The digital payments pioneer was already thriving, but COVID-19 kicked its growth into overdrive. PayPal moved quickly to roll out QR codes to provide additional touch-free payment options.

In the first quarter, PayPal added more than 20 million net new accounts, as its growth rate on that metric rose 17%. This brought its total to 325 million accounts, and that could be just the beginning. The company reported that after the close of the first quarter, it saw dramatic gains in transactions throughout April, and adoption and engagement trends accelerated in May.

"I would argue that April was probably the strongest month for PayPal since we became a public company," said CEO Dan Schulman in a May interview with MarketWatch. That strength continued into May as PayPal reported the largest single day of transactions in the company's history -- beating out 2019's Black Friday and Cyber Monday results. 

Digital payments are the future, and PayPal is helping pull that future into the present.

Family huddled around laptop looking at screen smiling

Image source: Getty Images.

3. Shopify: Bringing Main Street merchants into the e-commerce universe

As pervasive as e-commerce seems to have become already, it still has a long way to go. In the first quarter, online sales represented about 11% of total retail in the U.S. That's about three times the percentage they accounted for a decade ago, and the growth shows no sign of slowing. Arguably no company is better situated to benefit from this shift than Shopify (SHOP -2.37%).

As massive numbers of shoppers decided to forego visiting brick-and-mortar retailers in person in order to reduce their risk of exposure to the coronavirus, mom-and-pop shops were among the hardest hit. In response, many of those merchants turned to e-commerce for the first time. Shopify specializes in helping such businesses make the transition and keep their online operations running smoothly. The company offers turnkey technology solutions for those making the jump to online sales, with plans starting for as little as $29 a month.

Shopify offers far more than just help building a website. It connects retailers with payment solutions, shipping and logistics, inventory management, analytics, advertising, and even working-capital loans.

That was just what the doctor ordered when the pandemic struck. In April, Shopify reported helping thousands of new businesses move online and said it was generating Black Friday level traffic on its platform every day. 

That's not all. Between mid-March and late April, the number of new stores joining Shopify's platform grew 62% compared to the prior six weeks and customers making purchases from merchants they had never previously bought from online jumped 45%. 

The growth of e-commerce is just getting started, which provides a massive opportunity for Shopify.

A man in business attire touching a virtual cloud icon.

Image source: Getty Images.

4. Microsoft: Cloud computing and so much more

When tens of millions of employees left their offices and began working from home at the outset of the pandemic, the shift to a remote-work model posed challenges for many businesses. Companies that were able to help smooth that transition were positioned to reap the rewards, and one of those was Microsoft (MSFT -2.45%). More importantly, the same things that made its stock a buy as COVID-19 struck also make it a compelling choice to hold for the long term.

The need to conduct business doesn't just stop even if work must be done remotely, and remote work actually plays to many of Microsoft's strengths. Its commercial software products, including Office 365 (now called Microsoft 365) and Dynamics 365, are used by millions in their day-to-day business, and its Teams work collaboration platform has become a key tool for many companies over the past several months.

Cloud computing, too, has become more important than ever. Microsoft's Azure was experiencing impressive growth even before the pandemic, and that continued in the most recently reported quarter. Revenue from the intelligent cloud segment grew 27% year over year, driven primarily by Azure's 59% gains (61% excluding currency fluctuations), making this one of the company's biggest growth areas. 

"We've seen two years' worth of digital transformation in two months," said CEO Satya Nadella. "From remote teamwork and learning, to sales and customer service, to critical cloud infrastructure and security -- we are working alongside customers every day to help them adapt and stay open for business in a world of remote everything." 

With its fingers in everything from day-to-day business to cutting-edge cloud computing, Microsoft is a solid buy now and for the future.