All perfect praise be to Allaah, The Lord of the Worlds. I testify that there is none worthy of worship except Allaah, and that Muhammad is His slave and Messenger. We ask Allaah to exalt his mention as well as that of his family and all his companions.
A deposit is an amount of money which the Islamic bank or Islamic company asks the customer to pay in order to guarantee that he is seriously willing to buy. That is so, because the bank may be harmed when the customer refuses to buy, in which case it is permissible for the bank to deduct an amount from this deposit provided it is equal to the harm that it underwent. The bank is legally permitted to do so as this allows the stability of transactions and protects the money saved by the customers in this bank. This also prevents the customer [buyer] from playing around as this causes harm to the bank.
The Fiqh Islamic Committee in its conference held in 1983 issued the following report:
"The committee is of the view that taking a deposit in Al-Muraabahah transactions and other type of transactions is permissible on the condition that the bank has no right to take from the deposit except according to the harm that is really caused to it because of the customer refraining from buying."
It should be noted that the scholars differed in opinion with regard to a sale with a non-refundable deposit, the majority of them are of the view that this is not permissible, whereas the Hanbali school are of the view that it is permissible; their [Hanbali] evidence is that it is reported that Naafi' bought for 'Umar (the caliph) from Safwaan Ibn Umayyah a house to use as a prison, so the transaction was that 'Umar should agree otherwise he has to pay such and such for changing his mind. Al-Athram said: "I said to Ahmad: "Do you adopt this opinion?", he replied: "What else can I say? This is the opinion of 'Umar !" This story is mentioned by Ibn Qudaamah but it is originally taken from the Sunnan of Al-Bayhaqi. So the Hanbali school consider the narration which the majority of the scholars give as evidence on the permissibility of selling with a deposit, as week. This is the opinion that we have chosen, as it is more convenient to our time in carrying out transactions in a good and safe way.
This means that this amount [deposit] is not an investment in the first buy, rather it is a guarantee which proves that the customer is seriously buying, as you mentioned at the last part of your question.
Allaah Knows best.