When you deposit money with a bank, you are certainly not in a position of a lender and the bank is not a borrower. You have defined the relationship in a way which means that any returns given to you by the bank are legitimate earnings. As you realize, banks use the money they receive from their clients to lend it to borrowers, charging them interest, which means that they actually receive more than they give, in return for the loans they advance. Such transactions are forbidden in Islam. However, if you arrange with the bank that it invests your money for you in some way which does not involve lending to others with interests, then the return from such an investment may be legitimate to take.
Some banks invest in shares and unit trusts.
If the share they invest in are those of companies which do not trade in something forbidden, then such an investment is lawful. Quite recently, the Mufti of Egypt published a ruling stating that such an investment is lawful, even if the rate of returns is fixed at the outset. He makes it clear, however, that straightforward bank transactions of borrowing and lending, which involve interest are unlawful. If you wish to make use of the services provided by banks, you should bear in mind that any interest given on deposits used for lending is unlawful to have. If you give instructions in the bank to invest your money in a lawful way, as in a profit-loss sharing account, then the money you receive on your investments is perfectly legitimate.