This is certainly true. But it's also true that draining liquidity can be a dangerous move, especially when the economy stinks.
Over a very long period of time, plowing a pile of cash into the market is likely to "beat" prepaying a mortgage or holding a lot of cash. But not *all* of financial planning is about maximizing returns; some of it is about securing what you have as well.
If one prepays a mortgage with a lump sum of cash today, I only hope they either (a) can honestly and confidently state that they have a VERY secure income stream and (b) they still have a sound emergency fund. The worst thing one can do is take most of their liquid cash, prepay the mortgage, and then lose their job while the roof leaks and the car breaks down.
We're living in a time when liquidity is crucial to financial security for most people. And even if stockpiling cash at 2% stinks, it stinks less than having almost nothing in the bank when a pink slip heads your way.