With the stock market's recent wild volatility, if you're looking for the best way to invest $1,000 right now, you're not alone. Now, let's be clear: You shouldn't be investing money that you're going to need in the next few years. 

That said, if you're in a position to invest $1,000 in the stock market that you can leave in your portfolio for several years at least, here are two fantastic companies to consider buying with that amount right now.

1. Veeva Systems: A cloud stock with a twist 

The healthcare industry is always a durable place to invest your capital because it features companies providing essential -- and often lifesaving -- products, services, and technology that people need year-round, no matter what is happening out in the world, much less the stock market or economy. But most pharmaceutical companies would struggle to stay afloat without a way to manage all the data flowing in and out on a daily basis.

Enter Veeva Systems (VEEV 0.95%). Veeva is something of an anomaly in the world of cloud computing stocks in that its suite of products and services are entirely targeted toward the life sciences industry. From its software that streamlines everything from clinical data management to risk evaluation to quality control, to its business consulting services that cover everything from commercial strategy to research and development, Veeva's products and services are a one-stop-shop for some of the biggest names in healthcare today. We're talking companies including Eli Lilly, Roche, Bayer, Pfizer, Johnson & Johnson, and Merck.

Demand for the solutions Veeva Systems provides isn't going anywhere, and if anything, it's only growing. In the most recent quarter, total revenue surpassed Wall Street's expectations, up 17% year over year to $534.2 million. Veeva Systems is also profitable -- reporting net income of $90.6 million and operating income of $101.1 million in the quarter -- even though these figures represented declines of 17% and 19% from the year-ago period.

Management has attributed some of these developments to factors like currency headwinds. That, coupled with a pullback in earnings and revenue as Veeva heads into the more mature growth stage of its business, has all fed into the stock's decline of more than 30% this year.  

Taking a step back beyond recent earnings, over the last five years alone, Veeva Systems has grown its annual revenue, net income, and cash from operations by respective percentages of 168%, 183%, and 228%. Its current liquidity looks great as well, closing the most recent quarter with $1.1 billion in cash and cash equivalents on hand.  

While investor sentiment toward companies across a variety of industries has soured in recent months, including those in or around the healthcare space, Veeva's business is still strong. Some of the world's largest healthcare companies rely on the products and services it provides, and this fact gives it longevity that will outlast the current volatility and macro environment which many businesses are up against right now.

Based on its current share price, $1,000 would buy you approximately six shares of Veeva Systems.

2. UPS: Look beyond consumer spending headwinds

The parcel delivery market is facing some near-term headwinds with consumers more strapped for cash and scaling back on discretionary purchases. There are lingering challenges with supply chain management too. Yet, these issues will resolve in time. Buying shares of a market leader like United Parcel Service (UPS -0.11%) could leave investors well-positioned for strong portfolio growth as these headwinds eventually retreat. 

To lend some context here, the global courier, express, and parcel market hit a valuation just shy of $400 billion as of 2021, according to ResearchandMarkets.com. The same report estimates that this market will be worth $520 billion by 2027. And according to CSIMarket, UPS controls 39% of this industry, giving it an edge over well-known competitor FedEx's 36.6%.  

In the most recent quarter, UPS reported revenue growth of 6% year over year, while consolidated operating profits rose 9% and diluted earnings per share 8%. Taking a broader look back, in the trailing five-year period, the company has grown its annual revenue and net income by respective amounts of 46% and 163%.

And while not yet a Dividend Aristocrat, UPS has faithfully paid and raised its dividend for 22 years and counting, which currently yields 3.7%.

While customer delivery volumes may impact UPS in the near term, and its share price has declined as investors grow concerned over this fact, the company's financials are in excellent shape, and its market dominance leaves it well-positioned as inflation eventually dies down, and consumer spending recovers.

A $1,000 investment in UPS at its current price would provide about six shares to your portfolio.