You don't need to be a millionaire to invest in stocks. The key to earning great returns over long periods is to invest -- even modest sums -- regularly in excellent stocks and hold those shares for a while.

Dividend-paying corporations can be particularly great picks since the steady and reliable payouts they offer help boost total returns over the long run. Let's consider two such stocks that you can buy for less than the relatively modest sum of $500: Amgen (AMGN -1.73%) and Merck (MRK 0.26%).

1. Amgen

Amgen is a biotech leader with a plentiful and diverse lineup of medicines across multiple therapeutic areas. The drugmaker has outperformed the market in the past year despite a pullback following its latest quarterly update. Amgen's fourth-quarter financial results failed to impress investors due to nonexistent growth on both the top and bottom lines.

The company's revenue for the period remained flat at about $6.8 billion, while its adjusted net income dropped by 11% year over year to $2.2 billion. Amgen has been dealing with declining sales for some key products, including immunosuppressant Enbrel and neutropenia medicine Neulasta, for some time now due to competition (biosimilar and otherwise) and other factors. However, Amgen has devised a plan to boost its top-line growth.

The company has earned approvals relatively recently for therapies that could eventually become blockbusters -- that is, generate over $1 billion in annual sales. Asthma treatment Tezspire and cancer medicine Lumakras lead the pack; both first earned U.S. approval in 2021.

Amgen's pipeline also looks exciting, boasting nearly two dozen late-stage clinical trials alone. Amgen is particularly looking to be more active in the biosimilar market and is currently running phase 3 studies for biosimilar versions of famous blockbuster medicines, including Regeneron's wet macular degeneration (an eye disease) treatment, Eylea, and Johnson & Johnson's immunosuppressant, Stelara.

Biosimilars mimic the function of biologic medicines at a fraction of the cost. Since they allow patients and the entire healthcare system to cut costs, this industry has a bright future, and that's good news for Amgen. The company has plenty of other opportunities to replenish its lineup and return to growth over the long run.

A stronger business will also help support the drugmaker's dividend. The company has raised its payouts by 61% in the past five years, and its 3.51% dividend yield is well above the S&P 500's 1.74% average.

At current levels, investors can afford two shares of Amgen for $500. That could pay rich dividends down the road for those who can stay put for a while and add to their positions regularly.

2. Merck

With $500, investors can comfortably afford four shares of Merck right now with plenty of change to spare. Merck is a leader in both the human and animal health markets. In the former, it is best known for its blockbuster cancer drug Keytruda, which has earned an impressive number of indications and continues to garner more.

Keytruda has been unstoppable, growing its sales rapidly through virtually any economic or market condition. In the fourth quarter, sales of Keytruda jumped by 19% year over year (or 26% in constant currency) to $5.5 billion. Keytruda will hardly slow down until it loses patent exclusivity in 2028, which is still several years away. In the meantime, Merck is seeking ways to replace its crown jewel.

Some other products under the company's banner can continue to perform well despite appearances. In the fourth quarter, HPV vaccines Gardasil and Gardasil 9 saw their combined revenue decline by 4% year over year to $1.5 billion -- but these products' sales increased 6% year over year in constant currency. Importantly, Merck expects Gardasil's revenue to continue growing through 2030.

Elsewhere, cancer drugs Lynparza and Lenvima, as well as Merck's animal health unit, also registered decent performances in constant currency. Merck's total sales increased by 2% year over year to $13.8 billion, while its adjusted net income dropped by 10% year over year to $4.1 billion.

The company's pipeline currently includes more than 25 programs in phase 3 studies and more than 80 in the phase 2 stage. Those are impressive numbers that will eventually allow the drugmaker to return to solid revenue and earnings growth, especially once the effects of currency exchange dynamics ease.

In the past five years, Merck has raised its payouts by about 52%. The company's dividend yield is a solid 2.69%. And many more years of market-beating performances and dividend increases lie ahead for this pharma giant.