That is because of the Hadith of Abu Hurayrah (may Allah be pleased with him) who said: the Prophet (peace be upon him) said: “Increase in remembrance of the severer of pleasures." Meaning death.” 
The benefit of remembering death:
It generates diligence in work, preparation for the Hereafter, and turning away from the world, for it is full of deception.
Thabit Al Bunany, may Allah bless him, said: “Blessed is the one who remembers the hour of death. A slave (worshipper) does not increase the rememberance of death except the result can be seen in his actions.”
It is important for a Muslim to take heed of what he remembers of the reality that he will face which is death. Among the things that will help with this are: (visiting the graves). It is a Sunnah encouraged by the Prophet (peace be upon him) as reported in the Hadith of Ali (may Allah be pleased with him): “(In the past) I forbade you from visiting the graves, but visit them now for they will remind you of the Hereafter” and in a narration: “Remind you of death.” 
 Narrated by At-Tirmidhy number (2307). An-Nasa'y number (1825). Ibn Hibban authenticated it. “The destroyer of pleasures”: to cut them off. So, they cut the pleasures of the world and the heart yearns for the Hereafter. He narrates: “The destroyer of pleasures” as the destruction of the construction. Death destroys the construction of the pleasures of the world.
 Look at "Hiliyat Al Awliya'” (2/326)
 Narrated by Ahmad (1236) and its words are his. It is narrated by Muslim number (977) from the narration of Ibn Buraydah from his father, (may Allah be pleased with them).
 Narrated by An-Nasa'y number (2035). Narrated by Ibn Majah number (1572).
Please write: COMMENT in this box to verify that you are human