I was reading on the topic, and would like to be sure that my understanding is correct. For the benchmark I would consider American banking system as I've mostly used sources such as FRS and Federal Bank of New York when doing reading.
Banks are required to keep some percentage of their deposit money (say, 10%) in vault cash or at Fed. If the bank A does not have enough reserve, it has to borrow it either from another bank B (with an excess reserve) or directly from the Discount Window at Fed. The Discount rate at the latter is usually relatively high as Fed wants banks to borrow from each other, so bank A is likely to make an overnight loan with bank B. The rate at which this loan is made is called Fed Funds Effective Rate (well, the latter is a weighted average of all such rates) which is kept by Fed close to the target Fed Funds Rate by performing Open Market Operations. This is all clear to me.
What is not that clear are the reasons why some banks would have not enough reserves whereas others will have excess reserves. I guess, at least one reason is the change in the value of deposits: if bank A had 100M in deposits and kept 10M as a reserve, if 2M deposits were withdrawn then it has a reserve of 8M whereas it has to keep 9.8M = 10%$\times $98M reserves, so the bank A needs to get 1.8M somewhere.
I guess, there may be another reason which is heterogeneity in the investment opportunities. Suppose, bank A still holds 100M and has 10M in reserves. Now, there appears a very sweet deal which requires investing 1M today to get 2M back at the end of month. If bank A invests this 1M, then it has only 9M as reserves and needs to borrow 1M from somebody else. This somebody else may have excess reserves since such sweet deal was not available to him, it was only available to bank A - otherwise why give 1M to bank A for a fairly little interest, if you can double this money in a month.
My questions are: is this second reason underlying interbank lending reasonable? Is it also related to middle-term loans made at LIBOR rate (I don't think they are used just to meet reserve requirements, or are they)? Are there any other common reasons why banks borrow from each other - or equivalently why some banks would like to borrow whereas others would like to lend?