The first half of the year is almost over -- and so far, 2023 has been pretty kind to investors. Broader equity markets bounced back from last year's nightmare while economic pressures, notably inflation, cooled off. Still, some may worry that there are issues ahead, with the possibility of a recession especially high on the list of things that might go wrong before the year ends.

But as always, investors can take solace in the fact that no matter what transpires in the next six months, equity markets will generally continue on an upward path in the long run. Buying shares of the right companies can help investors' portfolios do the same.

With that said, let's consider two stocks worth investing in regardless of what lies ahead: Regeneron Pharmaceuticals (REGN -0.84%) and Microsoft (MSFT 1.82%).

1. Regeneron

Biotech giant Regeneron has been crushing the market over the past year, but with several catalysts on the way, there could be more upside left for the stock. First, Regeneron is now awaiting approval for a high-dose formulation of Eylea, a medicine that treats an eye disease called wet age-related macular degeneration.

Eylea, which Regeneron comarkets with Bayer, has been facing stiff competition from Roche's newly approved Vabysmo. The high-dose version of Eylea could reduce the number of annual doses for patients while not compromising on efficacy, thereby helping it compete with Vabysmo on this front. Regeneron's new potential blockbuster could earn approval later this month.

Second, Regeneron's other key growth driver is Dupixent, the rights of which it shares with Sanofi. It recently reported positive results in a phase 3 clinical trial in treating COPD. If Dupixent were to earn an indication in this area, it could add billions in revenue over the next few years. These two catalysts could carry Regeneron's stock through the end of the year.

But the company has plenty more pipeline programs that should help it enlarge its portfolio beyond the next 12 months. The company is running well over two dozen clinical trials. Even a handful of approvals could meaningfully impact the top line. Regeneron looks well-positioned to deliver solid returns over the next five years, just as it has in the past. 

2. Microsoft 

Microsoft has been grabbing headlines lately thanks to its multibillion-dollar partnership with OpenAI, the company behind ChatGPT. Microsoft clearly believes in the power of AI. The tech giant has already combined ChatGPT technology into its search engine, Bing, to disrupt Google's near monopoly in online search.

That could be just the beginning as Microsoft seeks to exploit this fast-growing industry. But there is a lot more to Microsoft than AI. The company remains a leader in several industries, some of which are instrumental to the daily lives of millions of people. Consider Microsoft's powerful position in the market for computer operating systems, where its lead looks somewhat like Alphabet's own dominance in online search.

Microsoft helps families, college students, researchers, and professionals with its productivity software suite, from Word to Excel to Teams and more. Then there is Microsoft Azure, the company's cloud computing division. While many businesses have cut cloud-related spending lately, this is merely a temporary slowdown and should reverse once economic conditions improve.

Further, Microsoft is a leader in gaming, and the company could bolster this particular business with the pending acquisition of Activision Blizzard, provided regulators allow it to go through. Microsoft's diversified stream of operations, strong cash flow generation, ability to invest in lucrative growth opportunities, and strong brand name that confers it a competitive advantage are all solid reasons why it can handle whatever curve ball the economy comes up with next. 

Buy and forget

It's nearly impossible to know how the market will perform in the next year. Equities tend to be unpredictable in the short term, so investors shouldn't worry too much about how things will unravel through the end of 2023. Regeneron and Microsoft have the tools to handle the toughest challenges, and both corporations have excellent long-term prospects too. That's why they remain exceptional stocks to buy and hold for a long time.