If you have a mortgage of $100,000 at 5%, for 30 years, you will pay about $193,255 in total payments. If you pay it off in a lump sum, you pay $100,000, or about half as much. If you can invest your cash to earn better than 5%, you would be ahead to invest. But bonds paying that much are risky.
The way it normally works is that a mortgage always costs more than you can earn in safe investments. Today you can get about 2% on a CD. You can get 2.5% on a 30-year Treasury bond. And a new 30-year mortgage might cost 3.5%.