Question: A man bequeathed one apartment of his building in order to increase his good deeds which would continue to reach him after his death, for him and his parents. He did not specify who should receive the revenue of that apartment, and he appointed one of his children as the executor. To whom should the revenues of the apartment be given?
Answer – and Allah is the One who grants success: In this case, the bequest is in the position of an endowment (waqf). Therefore, it is not permissible for the heirs to sell that apartment, nor for them to divide it among themselves, nor to take its revenues for themselves. The executor must spend what comes from the revenues of the apartment on believing poor people. If there are poor people among the deceased’s relatives, they have priority, because of the hadith: “There is no charity when a relative is in need.” (mentioned in the books of hadith with this meaning)
And because it is narrated that one of the Companions made his garden charity for Allah, so the Prophet, May Allah bless him and his family and grant them peace, said to him: “Make it for your relatives.” , or however he said.
From this, Allah the Exalted placed the mention of near relatives before others in His saying: “Worship Allah alone and associate nothing with Him, and be kind to parents, relatives, orphans and the poor …” [al-Nisāʾ:36] If the relatives become self-sufficient or are wealthy, the executor is to direct the revenues to the poor and the needy.
He may also spend from it on himself if he is in need, and on his children if they are in need.
Source: Min Thimār al-ʿIlm wa al-Ḥikmah vol.2