Eliminating debt, especially a mortgage is often the holy grail for many consumers, but allocating extra cash into the stock market can reap higher returns for retirement.

As interest rates for 30-year mortgages have fallen below 4% for an extended period of time and with some 15-year and adjustable rate mortgages dipping under 3%, homeowners should rethink their strategy.

Some celebrities have chosen to adopt a debt-free tactic: boxing champion Floyd Mayweather recently bought his $26 million mansion in Beverly Hills with cash. But he may have dealt himself a stiff blow.  Eliminating that monthly payment may seem like a good idea to avoid accruing interest and to remove clutter in your personal finance, but for most of us, having extra money on hand is helpful for emergencies such as floodwaters damaging your home and car. That's not to mention the fact that investing that money for the long-term will deliver better results for you that exceed the cost of your mortgage payments.

Paying off your debt is a good rule of thumb, but since mortgage debt is relatively inexpensive compared to credit cards, making a reasonable 20% downpayment and investing the rest of your money is your best bet. The extra money should be saved and invested in retirement accounts such as 401(k)s and IRAs, 529 college savings accounts and health savings accounts (HSAs), said Greg McBride, chief financial analyst for Bankrate, a NewYork-based financial content company.

"With the low cost of mortgage debt, particularly on an after-tax basis, it is a better use of excess cash to maximize tax-advantaged retirement savings accounts," he said.

Equity in a home is not always accessible, especially if there is a downturn in the economy and buyers are scarce.

"Why pour all that extra money into paying off a low rate mortgage?" McBride said. "You can't get to the money if you need it. Money in the bank will pay the bills, home equity will not."

Even people who have paid off their mortgage are facing other costs such as rising property taxes, property insurance, maintenance and upkeep of their home.

"Living mortgage free isn't the same as living rent free," he said. "If you've paid off your mortgage, you may have a lot less cash on hand to meet those other expenses."

Living debt-free has its advantages and paying off a mortgage gives homeowners peace of mind, especially if retirement is on the horizon, said Ron McCoy, a portfolio manager on Interactive Brokers Asset Management, the Boston-based online investing company and founder of Freedom Capital Advisors in Winter Garden, Fla.

"This bull is getting gray hair, so why risk going through another recession and stressing out," he said. "If you are investing rather than paying off mortgage, make damn sure you are in solid dividend payers."

The caveat is that investors actually invest the extra cash and not spend it on disposable items, said Bill DeShurko, president of 401 Advisor, a registered investment advisor in Centerville, Ohio.

"Always mortgage real estate," he said.

A homeowner who pays a $1,000 a month for 20 years could wind up paying less because of inflation. If inflation averages 2% over the next 20 years and your income stays up with inflation, since your mortgage payment is fixed, homeowners pay back the loan with less valuable dollars due to inflation, DeShurko said. The appreciation of real estate can also be beneficial.

"After 20 years, your $1,000 payment will only cost you $667.62 in 2037 dollars," he said. "Or looking at it the other way, for every $1,000 you make in 2017, you should be making $1,485.95 in 2037 if your earnings keep pace with a 2% inflation rate."

Choosing to invest $160,000 or approximately what you can borrow for $1,000 a month for 20 years in Proctor & Gamble (PG) stock 20 years ago would yield an investor more retirement savings.

"Remember, the stock market went nowhere from 2000 to 2013, but you would have received $2,124 in dividends and that is more than enough to pay your mortgage, taxes, insurance and have a little leftover," said DeShurko, whose firm focuses on stocks that pay increasing dividends, but do not currently own Proctor & Gamble stock because the price of stock at the last review was too high. "Today you would be getting $1,351 in dividends, have a paid off house and the value of your stock would be $397,136."

A homeowner who chose to pay their mortgage out of pocket, but reinvested the dividends of Proctor & Gamble would yield $18,152 in dividends in 2017 and the value of the stock would be $642,432.

"That sounds incredible, but this represents just a 7.1% rate of return on the stock price, but the dividends grew at an average rate of return of 9.8%," he said.

Investors tend to lose money investing in stocks beause they are too eager for immediate gains.

"People lose all their money in the stock market because they get greedy," DeShurko said. "Buy boring companies with a history of growing dividends for 20 years or more, currently have free cash flow to maintain their dividend payments and growth and revisit the stocks annually."

Mayweather may be the best boxer ever to step in a ring, but he has a thing or two to learn about real estate.  

Watch: Here Are the Biggest Pay-Per-View boxing Matches in History

More of What's Trending on TheStreet:

More from Debt Management

What Is Peer-to-Peer Lending?

What Is Peer-to-Peer Lending?

What Is a W-4 Form and How Do Allowances Work?

What Is a W-4 Form and How Do Allowances Work?

Top 7 Facebook Scams to Watch Out for in 2018

Top 7 Facebook Scams to Watch Out for in 2018

Average College Tuition: Increases and State-by-State Differences

Average College Tuition: Increases and State-by-State Differences

How to Make a Budget: 7 Easy Steps to Use Now

How to Make a Budget: 7 Easy Steps to Use Now