The reason you would invest while you still have debt is that you expect the return on the investment to be greater than the interest you are paying on the house. So if you are paying 4% but getting 8% on the MFs, then clearly you are coming out ahead. Also, at low interest rates, a mortgage can also be a hedge against inflation.
This is a huge subject of debate, but many financial professionals actually encourage people not to pay off their mortgages early.
For me, my comfort zone is somewhere in the middle. My mortgage situation is complicated, but in essence, I am working to pay it off somewhat early, but my focus is still mostly on investing. (I paid off the bank and now have a HELOC, which is at 2.6% but is adjustable so I want to get it gone before rates rise much. There is also a more traditional P=I loan at a higher rate that is from a family member, but it still paid like any other loan.) However, the mortgage amount is well less than we would net from a sale (even if prices drop, again), so if we ever needed to sell, even in a hurry and therefore at a less-than-optimal price, we could easily afford to do that. If I was underwater on the mortgage, then I'd work like hell to rectify that before doing much investing.
If you are in a position where you could sell your house without bringing money to the table (and could do so even if prices drop somewhat significantly), then to me, you aren't doing much "speculating", and you certainly aren't taking on much risk at all. If your loan rate is fairly low, then the difference in returns you can get by investing is, IMO, well worth the minimal risk.