Depositing money in riba-based banks out of necessity, in order to protect the money
Renting out a store or house to one who will use it for sinful purposes is not permissible; that includes renting out a building to a riba-based bank, because that is clearly helping in sin and transgression, because the owner of the building knows that the bank is renting this place in order to engage in haraam transactions such as riba etc.
Al-Bayhaqi said in Sharh Muntaha al-Iraadaat (2/358): it is not valid to rent out a house to be used as a church, synagogue or monastery, or for the sale of alcohol or for gambling etc., whether that is stipulated in the contract or is known by other means, because it is a haraam action and it is not permissible to rent it out for that purpose. End quote.
Depositing money in a riba-based bank is haraam, whether one earns interest or not, because the bank will take the money and lend it in return for interest.
But the scholars made an exception in one case, which is when a person fears for his wealth and there is no safe place to protect his money. In that case it is permissible for him to put it in a riba-based bank, based on the principle that in cases of necessity, forbidden things become permissible. In that case he must put it in a current account that does not bear interest, because in cases of necessity, things are only permitted as much as is needed; he needs to protect his money, but he does not need to deal in riba.
For information on the conditions of putting money in riba-based banks, please see question no. 22392.
And Allaah knows best.