The bottom line is that you need to do the math to determine whether it makes sense to take out a mortgage and invest or pay cash or pay off your home loan. For example, say you have a 15 year fixed mortgage at 5 1/2% with an initial balance of $150,000. Your payment is $1226/month or $14,708/year. $8,085 of that annual payment is interest.
You must first calculate your effective cost of money. The starting point is 5.5%. Then, you need to reduce that number by the mortgage deduction. If you are in the 25% federal marginal tax bracket, you reduce your effective cost of money by 25% to 4.125%. Additionally, the cost of money is reduced by the rate of inflation. Presently, it is running about 3%. This gets your effective cost of money down to about 1.125%. If you choose to invest the money, you will need to earn 1.125% to break even in the first year. However, the total interest paid annually is reduced each year and the tax reduction is reduced each year as well.
Another way to look at this is to consider the total tax benefit over the life of the loan. In this example, the total tax benefit is about $23,302 by maintaining the mortgage. However, if you choose to maintain the mortgage and invest, you must keep up with inflation. If inflation over the next 15 years is the same as the past 15 (2.65% annually,) you would need to make the $150,000 increase to $222,033 over the 15 years just keep up with inflation, a difference of $72,033. However, you will have the benefit of the tax reduction which will effectively reduce this amount to $48,731. In other words, you will need to turn your $150,000 into $198,731 in 15 years to break even on your decision to take out a mortgage rather than pay cash. In terms of rate of return, you would need to earn about 1.9% on your money to break even.
Keep in mind that you take on additional risk when you choose to invest. A mortgage payment provides a set rate of return, for lack of a better term. Investing involves market risk. Further, there are several factors which would impact this calculation. If inflation increases, you would need a higher rate of return on your investment than this calculation. If your mortgage interest rate is higher, the advantage to investing is reduced.
Note: This is a bit of an oversimplification. It took too long to post this as it is, let alone calculating the net present value of the tax deduction, for example. However, I hope it provides some food for thought.