Allaah has created man to worship Him. Allaah says (interpretation of the meaning):
“And I (Allaah) created not the jinn and mankind except that they should worship Me (Alone)”
Allaah has prescribed for him acts of worship by means of which he may attain great reward in this world and in the Hereafter.
These deeds and acts of worship are not limited to this world only, rather Allaah has prescribed means of increasing one’s good deeds after one’s death, namely ongoing charity (sadaqah jaariyah), as the Messenger (peace and blessings of Allaah be upon him) said: “When a man dies, his good deeds come to an end except three: ongoing charity, beneficial knowledge and a righteous son who will pray for him.” Narrated by Muslim, 3084.
Al-Nawawi (may Allaah have mercy on him) said in Sharh Muslim:
The scholars said: the meaning of this hadeeth is that the deeds of the deceased come to an end when he dies, and the renewal of reward ceases for him, except in these three cases, because he is the cause of them: his son is counted among his earnings, as is the knowledge that he leaves behind through teaching or writing, and ongoing charity, i.e., a waqf (Islamic endowment). End quote.
Ibn Maajah (224) narrated that Abu Hurayrah (may Allaah be pleased with him) said: The Messenger of Allaah (peace and blessings of Allaah be upon him) said: “The good deeds that will reach a believer after his death are: knowledge which he learned and then spread; a righteous son whom he leaves behind; a copy of the Qur’aan that he leaves as a legacy; a mosque that he built; a house that he built for wayfarers; a canal that he dug; or charity that he gave during his lifetime when he was in good health. These deeds will reach him after his death.” Classed as hasan by al-Albaani in Saheeh Ibn Maajah.