Source: U.S. Navy.

Imagine a married couple -- let's call them Matt and Donna Smith -- bought their dream house two years ago. The house was $250,000, and they paid $50,000 as a down payment. Since then, both have gotten raises, and with the extra cash, they are now asking themselves a crucial question: Should we pay off the mortgage early?

The math on this is clear: You should absolutely not pay off a mortgage early. You could lose money by doing this. But it's funny how math is much less absolute when it's dropped into the real world. There are hidden variables at play that make the decision to pay off a mortgage early the best option for the vast majority of Americans.

Here's why.

Couldn't I make more by paying the mortgage on schedule?
Mortgage rates are still at historical lows right now -- that's an important factor in the math. Back when Matt and Donna bought their house, they took out a 30-year, $200,000 mortgage with a 4% interest rate. That equates to monthly payments of roughly $950. But after getting their raises, they can throw $1,200 at the mortgage.

A quick Internet search showed that the stock market averages roughly a 9% return per year over long periods of time. "Even if it's only 6%," Donna thinks, "it makes more sense to invest our extra cash instead of putting it toward a home. The stock market can give us a higher return."

And, on paper, she's right. Here's how the two scenarios would play out in terms of the overall value, assuming the home's value continues to appreciate at roughly 3% per year, while the stock market returns its average 9%.

Source: Author's calculations. Home equity values calculated using amortization tables

Like any chart trying to predict the future, this isn't perfect. The family could move, wages could rise, or any other number of variables could change. But the bottom line is clear: Using this simple math, not paying off a mortgage early means more money in your pocket (and house) at the end of 30 years.

Who wouldn't want more money when all is said and done?

Can you really expect returns like that?
Here's where the first lurking variable rears its ugly head. It is true that the S&P 500 -- since as far back as 1871 (though it wasn't technically the S&P 500 then) -- has returned an annualized gain of 9.07% per year after dividends are reinvested. If every investor like Matt and Donna got returns like that, that would be phenomenal.

The problem is that the average investor does far, far worse than 9.07%. In fact, a recent release by JPMorgan Funds shows just how poorly the average investor has done over the last 20 years: 2.5% per year.

Why does this happen?

In a nutshell, the average person is not a good investor. They buy high, sell low, and generally shoot themselves in the foot over and over again by paying high fees. Because of this painful truth, paying off a mortgage early looks like a much better decision.

Of course, if you have a track record of successfully controlling your emotions and holding stocks for the long run, this might not apply to you.

But another key variable might.

What's your goal: money or financial independence?
Earlier, I wrote: "Who wouldn't want more money when all is said and done?"

Admittedly, that was a loaded question; there's a caveat to it. What if you have less money but also a greater sense of financial independence? Would that change things? There's nothing that can match the feeling of knowing you own your home outright and the bank can't take it away. There's also nothing like knowing you never have to make a rent or mortgage payment again for the rest of your life.

Wes Moss, author of You Can Retire Sooner Than You Think, has found -- in his own surveys -- that the psychological benefits of paying off a mortgage early are undeniable: "There's a world of happiness and freedom out there just waiting for you once your biggest monthly expense is eliminated. ... Happiness levels rise undeniably as mortgages vanish." 

So, even if you have more money by not paying off the mortgage early, is it worth sacrificing the happiness you'll experience by shedding the payment years -- even decades -- in advance?