If you were invested in the stock market in 2019, you're probably grinning from ear to ear. When the curtain closed on the year, the benchmark S&P 500 had gained 29%, with the tech-heavy Nasdaq and iconic Dow Jones Industrial Average tacking on gains of 35% and 22%, respectively. By comparison, the benchmark S&P 500 has historically gained 7% per year, inclusive of dividend reinvestment and when adjusted for inflation.

The data doesn't lie: Being a long-term investor in high-quality companies can be highly rewarding. But does this mean Social Security's 64 million beneficiaries (and more specifically, its 45 million retired workers) should consider putting their benefit checks to work in the stock market?

A senior counting a fanned pile of cash bills in his hands.

Image source: Getty Images.

Believe it or not, the answer isn't as cut-and-dried as you might think.

While there are instances where investing your Social Security benefit in the market makes a lot of sense, there are other situations where it would actually be a poor idea. Let's dig a bit deeper.

Investing your Social Security benefit in the market makes sense in certain cases

Let's examine a handful of situations where it would make sense to consider putting your money to work in the stock market.

The most obvious scenario would be if you're not in any way reliant on your Social Security benefit to make ends meet. According to a Gallup survey from October 2019, only 1 in 10 current retirees would be financially sound without their Social Security benefit. If you don't depend on your Social Security income, one of the many options you'll have, besides putting this money toward hobbies or entertainment, is to invest it in the stock market.

Keep in mind here that folks who are more financially sound in retirement often tend to live longer. That's because the well-to-do won't usually have financial constraints when it comes to receiving preventive care, medical care, or prescription medicines. Therefore, well-to-do Americans who choose to invest their Social Security benefit in the stock market are more likely to be able to take advantage of longer-term compounding gains and see their investments grow in value over time.

Two Social Security cards lying atop a one hundred dollar bill.

Image source: Getty Images.

The other stand-out scenario where investing your benefits could make sense is if you're only counting on Social Security as a very minor source of income, and you have longevity on your side. Understandably, no one knows their expiration date. So when I say "have longevity on your side," I'm really talking about a person being in good or excellent health and having immediate family members (such as parents or siblings) who live well into their 80s, 90s, or longer.

The point is, not being too reliant on Social Security income, and being able to see your investments grow over a long period of time (say, 10 years at minimum) is the pivot point where investing your benefits probably makes sense.

Here's when investing your payout is a bad idea

But there's another side to this debate that you should be aware of.

For example, in most instances it would be a bad idea to claim your Social Security benefit early in order to give yourself extra years to invest. Don't get me wrong: On paper, the idea sounds great -- especially after the 29% gain delivered by the S&P 500 in 2019. But there's a guaranteed "gain" that beneficiaries forgo by making this move.

As you might already know, Social Security retirement benefits can begin at age 62, or any point thereafter. But this is a program that rewards patience. For each year that eligible beneficiaries hold off on taking their payout, it grows by up to 8%, until age 70. Therefore, all things being equal (i.e., work history, earnings history, and birth year), retired workers claiming their payout at 70 can receive up to 76% more per month than retired workers claiming as early as possible (62).

Put another way, there's no guarantee that your return in the stock market is going to outpace this guaranteed "return" from Social Security for doing nothing more than waiting. Remember: The average historical annual return of the market is 7%, but some years of waiting on Social Security mean an 8% boost to your eventual payout.

A person circling a bottom in a chart following a recession.

Image source: Getty Images.

It also makes little sense to invest your Social Security benefit if it's a major or primary source of income. The stock market involves risk, and if Social Security income is how you pay your expenses, then it's money you can't afford to risk.

Retired workers would also be discouraged from putting any of their payout to work that they expect to need within the next three to five years. Although the stock market has historically been the greatest creator of wealth, its short-term movements are wholly unpredictable. If you invest looking for a quick buck, the market could burn you.

There's no simple answer to whether or not you should invest your Social Security benefit in the stock market. It depends on individual financial and health factors that every retired worker will need to assess.