The stock market can take investors for a wild ride, and that's especially true if you stay invested in the market for years at a time. While the downside of holding onto stocks through thick and thin is that you will likely encounter turbulence in your investing journey, that also means you'll be ready to benefit from the best days in the market.

If you have $1,000 to invest in stocks right now, there are plenty of fantastic businesses begging to be bought. Here are two such companies that you can buy and hold onto for a decade or more.

1. Microsoft

Microsoft (MSFT -1.36%) is a prime example of the old mantra, "if it ain't broke don't fix it." The tech giant has been a market leader for decades and continues to expand and seize market share with its lineup of innovative products and services.

The company's diverse business segments bring in revenue from a wide variety of sources including its flagship office productivity software, cloud services, hardware products like gaming consoles and tablets, advertising, social media platform LinkedIn, and more. Currently, Microsoft controls a 30% share of the multibillion-dollar global office productivity software market. In the lucrative cloud infrastructure market, which hit a global valuation of approximately $74 billion as of the end of last year, Microsoft accounts for about 24% of all spending.

The company's investments in artificial intelligence (AI) have been widely publicized. From pumping billions of dollars into organizations like OpenAI and Mistral AI, to incorporating AI into properties like Bing, its office software tools, and its cloud platform Azure, Microsoft is preparing for the future of the industries in which it operates and doing what it takes now to remain competitive in the long run.

Newer products like Microsoft Copilot allow users to leverage the power of generative AI to do everything from getting quick summaries of meetings to making better PowerPoint presentations. In the company's earnings call for its fiscal second quarter, CEO Satya Nadella noted that early Copilot deployment for Microsoft 365 users achieved a 29% improvement in productivity for tasks like writing and summarizing. Big-name clients Honda and Pfizer are already using these processes to help their employees be more efficient handling day-to-day tasks.

Several years back, Microsoft acquired developer platform GitHub, which allows users to store and collaborate on coding projects. That platform's incorporation of AI developer tool GitHub Copilot helped drive a 40% year-over-year revenue increase in the most recent quarter. Management also reported that it had 1.3 million paid GitHub Copilot subscribers at the end of the quarter, up 30% sequentially. Companies including Goldman Sachs, Dell, and Etsy are Github Copilot users.

Microsoft brought in total revenue of $62 billion in the most recent quarter (ended Dec. 31, 2023), up 18% year over year, while net income totaled $22 billion, a 33% year-over-year increase. The company also had a whopping $81 billion in cash and investments on its balance sheet at the end of that period. This business still looks like a no-brainer buy to start or add to a position for the long run, whether you're a seasoned investor or are just starting out on your long-term investing journey.

2. PayPal

PayPal (PYPL 1.86%) has had a turbulent few years following the height of its popularity during the pandemic and the wave of new users during the surge of online shopping in that time. The stock's performance has been more lackluster of late amid a slowdown in growth, users, and the overall challenges presented by the global economy, and some investors have felt less than enthused about what the business has to offer over the long term.

In my view, that looks like a short-sighted assessment. First of all, PayPal is still the leading payment processing provider globally, which is no small feat given the competition in this fast-growing space. At last count, the company controlled a whopping 45% of the entire global payment processing market.

Now, it's true that PayPal's growth story is highly connected to the overall trajectory of discretionary spending, particularly through mediums like e-commerce. While e-commerce spending is in flux right now as many consumer wallets remained constrained globally, these are relatively short-term headwinds when you're looking at an investment window of 10 years or more.

Global e-commerce spending is on track to hit a valuation of nearly $50 trillion by the year 2030. In short, there's plenty of room left to run here even with the emergence of other competitors in the payment processing space. And PayPal's financials are looking pretty solid overall, despite the ongoing challenges.

In the full year 2023, PayPal reported net revenue of approximately $30 billion, up 8% from 2022. Compare that to the company's full-year 2020 revenue, which came in at around $22 billion, and you have a three-year growth rate of about 36%. While transaction margin dollars and active accounts decreased by respective amounts of 1% and 2% in 2023, PayPal's total payment volume last year jumped 13% from 2022 to $1.5 trillion.

PayPal reported that payment transactions increased a healthy 12% in 2023 to $25 billion, and payment transactions per active account rose 14% on a trailing-12-month basis as of the end of the year. The company generated operating cash flow of $4.8 billion and free cash flow of $4.2 billion in the 12-month period. PayPal also improved its bottom line in 2023 to the tune of about 76%, reporting a profit according to generally accepted accounting principles (GAAP) of around $4.2 billion. With the stock trading at a price-to-sales ratio of about 2.4, now could be a good time to scoop up even a few shares at a discount.