Allaah and His Messenger (peace and blessings of Allaah be upon him) have commanded us to render back trusts to their owners. Allaah says (interpretation of the meaning):
“Verily, Allaah commands that you should render back the trusts to those, to whom they are due”
And the Prophet (peace and blessings of Allaah be upon him) said: “Render back trusts to those who entrusted you with them.” Narrated by al-Tirmidhi, 1264; classed as saheeh by al-Albaani in Jaami’ al-Tirmidhi.
So what you have to do is to return the money to its owner. You have to look for him and ask for him, and keep on trying to get in touch with him until you find him.
If you cannot find him then you have to keep his money for him until he comes and asks for it. In that case you may give it in charity on behalf of its owner – after doing your utmost to return it to him – then if he comes along one day you should tell him what you have done. If he agrees to the act of charity, he will be rewarded for it, but if he wants to take his money, then you will be rewarded for the act of charity.
The Standing Committee for Issuing Fatwas was asked about a man who left something for safekeeping with another person and did not come back to collect it, and many years had passed.
You have to do your utmost to find the owner of this trust. If you find him or one of his heirs then give it to him. If you cannot find him then donate it to some charitable cause, with the intention of giving charity on behalf of the owner. If the owner or his heir comes along after that, then tell him what you have done. If he approves of that, all well and good, but if he does not approve, give him the equivalent amount, and you will have the reward for what you gave in charity, in sha Allaah.
Fataawa al-Lajnah al-Daa’imah, 15/404
The Standing Committee was also asked about a man who left a sum of money with another man for safekeeping, then he went back to his own country and did not come back. The person with whom the money was left does not know what town the man came from. What should he do with this money?
If the situation is as you describe, then if you wish you may keep it and try hard to find out where this man is, or if you wish you may give it in charity to the poor, or donate it to some other charitable cause with the intention that the reward for that should go to its owner. If the owner or his heir comes to you after that, then tell him what happened. If he approves, all well and good, otherwise give him the same amount of money, and you will have the reward in sha Allaah.
Fataawa al-Lajnah al-Daa’imah, 15/406.