At the very least, during periods when interest rates are significantly above your mortgage rate, such as now, you should put it in a money market account instead of in your mortgage. It's the same amount of risk, but it's liquid. Really, you could do a long term Treasury bond for the same reasoning (same risk, same liquidity).
The returns from investment are estimated based on historical performance. You can lose money investing, not so paying off a mortgage early.