Banks do this in a variety of ways. They charge interest on loans. The answer is from their depositors and from the Fed. They pay interest to depositors but charge a higher rate on money they lend out. In the case of money borrowed from the Fed, banks pay a percentage rate on money they borrow, called the discount rate .
Banks then loan that money and charge a higher rate on the loan then the rate that they paid.
Banks operate on fractionalized deposits . They do not keep all of the depositors money on hand. They use depositors money to make money. They do this usually by giving loans and earning interest. Usually these loans are real estate loans, sometimes they are car loans, student loans etc.