In the Sahih of Al-Bukhari and Muslim, it is reported that Anas ibn Malik narrated that the Prophet said: “Three things follow the deceased person (to the grave), two of them return, and only one remains. His family, wealth and actions follow him. His family and wealth return, but his deeds will remain.”
Al-Hafidh Ibn Hajar said in his Fathu’l Bari, “The meaning of‘his deeds remain’ is that he will enter the grave with them”, whether they were righteous or evil. Man is therefore encouraged to have a righteous family that he lives with, and wealth that he supports them and himself with so that when these two companions inevitably leave him, they may continue to be a source of reward for him.
The intelligent person is the one who takes from these things sufficiently to help him in the remembrance of Allah, and what will benefit him in the next life. Thus he takes from his wealth what helps him in reaching the success of the next life and takes a righteous spouse to assist him in his faith. He must never be deluded by this world and its dazzles, its beauty and splendors, such that he preoccupies himself with it at the expense of occupying himself with what is eternal and everlasting (i.e. the Hereafter).
As for the person who has taken wealth and family as a distraction from Allah then he is indeed a loser. As Allah Said, “O you who believe! Let not your properties or your children divert you from the remembrance of Allah. And whosoever does that, then they are the losers.” [Surah Al-Munafiqun 63: 9]
He, the Most High, also Said, “And it is not your wealth or your children that bring you nearer to Us in position, but it is by being] one who has believed and done righteousness.” [Saba 34:37]
Al-Hakim recorded in his Mustadrak (4/324), “O son of Adam, live as you want for you will die. Love who you want, for you will leave him. Do what you want, for you will meet your actions. And be however you wish. And as you do, you will be recompensed.”