Subprime loans in the United States refer to loans issued by people with low credit ratings. These loans are mainly used to buy a house. Because the people with these loans have low credit rating and may not be able to pay back the money, they are called subprime loans. Its main feature is high interest rate, but high risk. In order not to bear the risk that the loan may not be repaid, commercial banks package the loan and sell it to investment banks as financial derivatives. Because this derivative is the lever of subprime loan interest rate, it is linked to repayment ability, and repayment ability is obviously related to house price. When the house price rises, even if the borrower does not repay, the bank will not lose money because of selling the house, but if the house price falls and the borrower can't bear it, then this risk will be transferred to the investment bank through the leverage of financial derivatives, and the investment bank will bring risks to the whole financial market because of its role in the financial market. This is the origin of the current financial crisis.
As for why investment banks can make money when housing prices rise, because investment banks are the real bearers of subprime mortgage risks, and of course they are the biggest beneficiaries when there is no risk. Just like an insurance company, if no one is in danger, it will earn more. All insurance companies can lose money if the insurance policy it receives is out of danger. This is the case in financial markets, where risks are positively related to profits.