I know that banks primarily make money from the 'spread', that is, people deposit their money in the bank and the bank pays them back with interest, and the bank lends that money to other people and they pay the money back to the bank at a lower rate of interest. When the Federal Reserve raises interest rates, fewer people borrow money. I assume that since fewer people borrow money, the bank makes less money, although the bank makes more money from each borrower. But at the same time, more people deposit money and the bank must pay them back the money at a higher interest rate. Where does the money that the bank now pays to depositors come from? I guessed that the Federal Reserve 'prints' (I know it literally doesn't print it) money and gives it to the banks.
Commercial banks can choose which interest rates to set (within limits). They will always try to set their rates such that interest charged on loans is higher than interest paid on deposits. So, as you say, they make indeed money from these margins ("spread"). Btw, that spread has to cover their operating costs (and other things) before they make profits and sometimes this is not possible. If they are making losses, these come out of the banks' capital, they are not offset by the Fed. The Fed comes into play in many other regards.
And indeed, as you say, usually the higher interest rates (influenced by the Fed's policy), the less demand for loans, and the more willingness to deposit, other things equal. But in reality it will generally also depend on the economic outlook. For example, if the outlook is good, customers are happy to pay higher interest rates on loans for investment, if they expect even higher returns on their investment, and the other way round. In any case, the bank can still offer interest rates sufficiently low that it still makes money.
Both interest rates and loan volumes come into play for banks to make money. Look at two extreme (simplified) cases:
- Interest rates are zero, and volumes are the highest. The bank will make no money.
- Interest rates are prohibitively high, so volumes are zero. The bank will make no money.
There is a sweetspot somewhere between those two cases where the bank makes the most money, that is where both interest rates and volumes are optimal, again other things equal.
Many banks currently don't make much money or even losses from retail banking, because interest rates are so low, and the low margins (partly due to increasing competition from non-traditional lenders) are barely sufficient to cover their operating costs.