If you invest for the long term, you don't need to worry about short-term fluctuations in the market or what retail investors are betting on today. But in order to be able to just buy and forget, it's important to look at businesses that are both sound financially and likely to enjoy strong demand for its products for many years. 

Two stocks that fall into that category are DexCom (DXCM 0.87%) and Microsoft (MSFT -0.74%). They're good buys today and look even better over the long haul.

An advisor showing a tablet to a couple.

Image source: Getty Images

1. DexCom

Diabetes is, unfortunately, a growing problem in the world. One in three Americans could have the illness by 2050, according to the Centers for Disease Control and Prevention. Luckily, DexCom and its continuous glucose monitoring devices can help patients manage the issue. Using small sensors that can be inserted under a person's skin, they make it easy to obtain glucose values and can relay and share those readings through an app. And the devices don't require finger pricks.

Demand for the company's products is likely to be around for a very long time, making Dexcom a sound long-term investment. The business itself has impressive margins and consistently posts strong profits. Its gross margin is a steady 69% of revenue over the trailing 12 months. Unsurprisingly, with that much left over after cost of goods sold, DexCom has also banked a 24% profit margin. The business has become more efficient over the years in keeping its expenses down (with respect to revenue), and if it can maintain these types of margins, there will be tons of profit growth in the future as sales continue to rise.

Through the first six months of 2021, DexCom reported $1.1 billion in revenue, which grew 28% year over year. Its net profit of $103 million rose by 56%. For the full year, the healthcare company projects that revenue will come in between $2.35 billion and $2.4 billion, growing at least 22% from 2020. But over the long term, there will undoubtedly be even more growth, and that's what makes DexCom an excellent option for investors who want a great stock they can buy and forget about.

2. Microsoft

Microsoft is an easy investment to justify over the long term. It's been a big name in its industry for decades, and that's unlikely to change. With so many different businesses that it can tap into for growth, Microsoft is versatile enough that it can change and adapt to ongoing trends.

One example is in the growing popularity of videoconferencing. Zoom Video Communications (ZM -0.47%) has experienced significant growth since the start of the pandemic, with people stuck at home and relying on its videoconferencing software for meetings (whether it was for business or any other reason). Since the beginning of 2020, the stock soared more than 300% while the S&P 500 increased by 40%. That wasn't an area of focus for Microsoft, but that has quickly changed for the tech company. Now, Microsoft includes videoconferencing capabilities in its Teams communication platform, which is designed to help businesses stay connected. Plus, it added a "Meet Now" option right within its Windows 10 operating system.

Microsoft is such a force that once it spots a trend, it can pour money into an area of its business to take advantage of it. With deep pockets (last fiscal year alone, it banked more than $61 billion in profit) and 1.3 billion devices that are currently using its Windows 10 software, it has the capability to easily reach users and deploy tools that can rival just about anything that's available in the marketplace today. 

And with so many different products and services, Microsoft is a safe bet to meet the needs of its users for the long term. From gaming to office software to cloud computing, Microsoft has many segments in its business. In its most recent quarter, for the period ending June 30, the company posted revenue of $46 billion, which rose 21% year over year, and its net income of $17 billion rose by 42%. And more importantly, many of its segments experienced growth rates of more than 10%.

With stellar numbers, a solid user base, and diverse offerings, Microsoft is a company that is likely to be a relevant player in tech for a long time to come.