When you borrow money, the lender usually wants to restrict how the funds are used. Loan interest rates typically take into account the risk that the lender expects to take. Riskier loans have different terms than less-risky loans.
For example, a mortgage is (supposedly) used to purchase a home -- which the lender can take possession of and sell if you default on your payments. Likewise, student loans are presumably used for education. The government subsidizes some student-loan interest because it's a good investment in the country. Furthermore, banks are willing to offer attractive student loans because statistics show that college educated adults will be more likely to have the income needed for repayment.
If your contract/agreement says that you must use the funds for a certain purpose, you risk violating the contract. If you fail to keep your end of the bargain, the lender may want to end the agreement and take the money back (youll end up without an 'enforceable contract'). Getting the money back quickly and without cost may be a challenge. For example, you may have to pay a penalty on early distribution from a CD.
Technically, using your loan money for alternative purposes may not be illegal. However, there is a possible risk that your lender will take legal action against you (if they find out that youve used the money in a different way than you promised).

