The Prophet (sal Allahu alaihi wa sallam) said in the hadith of Ibn Abbas, “If you take care of the commands of Allah, Allah will take care of you (and you will find Allah with you).”
How does that happen? Ibn Rajab al-Hanbali explains the hadith:
1. If you take care of Allah's commands and prohibitions, Allah will take care of you by keeping you away from vain desires and doubts in Imaan (Belief);
2. If you take care of the commands of Allah when you are young, Allah will take care of you in your old age;
3. If you take care of the commands of Allah, Allah will take care of your children.
As an example of the last point Ibn Rajab gave the story of Musa and al-Khidr. Allah (subhana wa ta'ala) says in the , “Then they both (Musa and al-Khidr) proceeded, till, when they came to the people of a town, they asked them for food, but they refused to entertain them. Then they found therein a wall about to collapse and he (Khidr) set it up straight. (Musa) said: ‘If you had wished, surely, you could have taken wages for it!’” [18:77] Then Al-Khidr explains why he fixed the wall for free in a town whose people were so mean and inhospitable, “And as for the wall, it belonged to two orphan boys in the town; and there was under it a treasure belonging to them; and their father was a righteous man, and your Lord intended that they should attain their age of full strength and take out their treasure as a mercy from your Lord. And I did it not of my own accord. That is the interpretation of those (things) over which you could not hold patience.” [Al-Quran 18:82]
From this story we learn that Allah (subhana wa ta'ala) took care of the orphans because their father was righteous! These orphans were not old enough to be considered righteous or not, but the reason that Allah (subhana wa ta'ala) took care of their treasure was because their father had been a righteous man. Since the father had passed away, Allah (subhana wa ta'ala) protected the man’s children by sending al-Khidr all the way just to fix that wall. So if you are righteous, not only will Allah take care of your children while you are alive, but He will take care of them after you die too. What’s better than that? Therefore, we need to take the commands and prohibitions of Allah (subhana wa ta'ala) seriously.