In theory this construction is favorable for the debtor, because the expected return of the investment funds is higher than the interest payed for the loan and the investment funds is a "secure investment".
Even without any knowledge about investment funds and returns one should try to use simple logic: When a bank really knows about a secure investment with a higher return, why shouldn't the bank invest in it instead giving a loan to the debtor?
The only thing this construction is useful and that is fraud.
There is no other way. Either the bank truely believes that the investment is safer and brings more returns than the loan - in that case the bank is giving money away, what is only conceivable if the bank employee is colluding with the debtor and is betraying his employer. The much more probable variant is of course that the bank does not believe that the investment is not safer and/or bringing more returns - in that case the debtor is betrayed because the product was sold to him under false pretenses.
During the crash preceding the Great Depression 1929, many livelyhoods were destroyed because people have speculated on credit. As dangerous as this practice may be, it can work if you really know a better investment than the bank does.
However when you get the investment from the same bank where you get the loan, that becomes impossible. The bank must hold the opinion that the investment is worse, otherwise it would not give you the loan.