The only time it makes sense to borrow money for an investment—known in financial lingo as "invest a loan"—is when the return on investment of the loan is high and the risk level of the investment is low. It is inadvisable for an investor to invest a loan in a risky vehicle, like the stock market or derivatives.
Also, if an investor takes out a loan it does not make sense to place the money in an investment that will mature after the loan is due. It is also important that the investor makes sure that the return on investment is greater than the cost of the loan.
Having a firm understanding of how and when leverage and margin come into play can also help an investor answer this question.