Share prices of e-commerce software company Shopify (SHOP 3.42%) had been gaining momentum of late until fourth-quarter earnings disappointed Wall Street. The stock still sits 75% from its high, and an uncertain economic environment could prove troublesome through the first quarter of 2023.

While some may question whether the stock can ever regain the highs it saw in a euphoric bull market two years ago, I remain confident that Shopify will eventually reach new heights. Here's why I'm so optimistic about Shopify's future.

Shopify plays a pivotal role in e-commerce

E-commerce is the future of retail and is already here in some ways. Today, roughly 15% of retail sales in the United States are online, a slow and steady crawl higher since the internet went mainstream approximately two decades ago. But the competitive landscape of e-commerce is very top-heavy. Amazon (AMZN 0.81%) and Walmart alone have roughly 44% of America's online market.

So what happens if you're a merchant, big or small, that wants to sell online to stay competitive? Shopify helps solve this problem. The company provides the software tools to open, operate, and grow an online store. Shopify's products and services range from facilitating payments, to supply chain and fulfillment, to marketing. Rather than try to build every aspect of an e-commerce business, a merchant can employ Shopify to provide and/or manage everything it needs from the jump. Shopify makes money via subscriptions, fees, and other charges, based on what services or products the merchant uses.

This niche has proven valuable; Shopify's cumulative merchants represent roughly 10% of e-commerce sales in the United States today. Merchants can be as small as a one-person start-up and as large as major brands like Mattel and Nestlé.

Investing in a competitive advantage

Shopify took a financial step backward over the past couple of years. For a while, it was generating hundreds of millions of dollars in free cash flow, but now the company is back to burning cash. It's not that Shopify's unable to make money; you can see in the chart below that gross profit has grown without much interruption for many years.

SHOP Gross Profit (TTM) Chart

SHOP Gross Profit (TTM) data by YCharts

Fulfillment services have been a focus area as Shopify invests in fleshing out its ecosystem of merchant solutions. It acquired Deliverr last year for $2.1 billion to help offer merchants services for fulfillment, freight, and returns. Logistics can be tremendously expensive to build; ask Amazon.

But fulfillment is now an integral part of competing in e-commerce. Successfully building out the challenging aspects of the e-commerce business model will only contribute to a moat that keeps competitors at bay. It's also necessary to keep pace with Amazon, which has fought back against Shopify with its Buy with Prime launch.

Investors must think long-term

Shopify stock looks like a bargain at first glance. It's trading near the low end of its historical valuation range with a price-to-sales (P/S) ratio of just over 9. However, Shopify's increased investments and negative free cash flow justify a lower valuation.

SHOP PS Ratio Chart

SHOP PS Ratio data by YCharts

Investors looking for a quick score might not like this situation, but I still believe there's a lot of upside ahead for long-term investors with some patience. The company operates in a virtual greenfield; the global retail landscape is tremendous, and even after two decades, e-commerce has taken over about 15% of retail in America. Shopify's investments are arguably necessary to cement its competitive edge and remain a viable alternative for merchants who don't want to work with Amazon (which indirectly competes with third-party merchants).

Shopify must continually execute at a high level. Still, the company's long-term opportunity to become a must-have for merchants worldwide makes it a stock that long-term investors can get behind.