If not, and a contract was made for that purpose. Let's say the loaner, loaned $5k and was promised back $10k.
Would the borrower still be obliged to give $10k
even though the contract is not legal?
Whoever thinks they can lend someone $5,000 and get back $10,000 is talking about scamming.
There is nothing inherently illegal or unenforceable for a contract concerning trading stocks. However, there are a lot more questions that would need to be answered in order to know for sure, including what state you are in. There may be a requirement for the person doing the investing to be a Registered Investment Advisor, depending on the state and the number of people the person is doing this for (most states have a de minimus exception to registration). Even if the contract is unenforceable, it still would not typically allow the person taking the money to invest to just ignore it. The money would still have to be repaid, regardless of the legality or enforceability of the full agreement.