Time in the market always beats timing the market. If someone will give you a 0% loan allowing you to leave an extra $20k invested for 5 years the smart thing is to take it every time. Doing that repeatedly over 30 years you win around 98% of the time.
There is a lot of truth in there, and it's good advice for people with plenty of assets and money. However, such talk diminishes the risk for those with less money. Take for example all those people who bought multiple homes around 2006 and 2007 with the easy money low interest loans, because housing prices could never go down, so they'd sell them for a nice profit before having to pay much on the houses. Those people were wiped out. That car loan of $5K people are talking about, let's say someone does that just before the market has a downturn. There is a near 100% chance (historically speaking) that over 5+ years the market will be higher than at the start of that period, but that loan doesn't get paid off at the end of the 5 years. It needs to be paid monthly. Let's take a hypothetical 1% loan for $5K, with a market that declines in the first 2 years then rises for 3 years.
A loan at 1% would be $85 per month, or $1,025 per year, total interest paid after 5 years of 2.5%. Let's say the market does this in 5 years:
-25%, -25%, +33%, +33%, +25%
Over 4 years the investment will have recovered to break even and over 5 years the original investment will be up 25%, which is far better than paying 2.5% interest. Hold on a sec though, that loan needs to be paid monthly. To keep it simple, I'll make it annual:
End of year 1: Investment now $4,000, pay out $1,025 to cover loan, have $2,975 left
End of year 2: Investment now $2,230, pay out $1,025 to cover loan, have $1,200 left
End of year 3: Investment now $1,600, pay out $1,025 to cover loan, have $580 left
Year 4: You're screwed, you can't pay off the loan, and you still have about a year and a half left.
If you have other assets to sell, other spare disposable income, etc. you can cover that and in the long term you'll be fine. However the fact that you need to sell investments or not invest that money in order to pay that debt goes against the original advice given here, but sure in the long run you'll likely end up better off. If you don't have other assets, you're screwed, you can't pay off that loan and you've lost a big chunk of your original savings.