It is a Sunnah to visit graves as they remind one of death
The Messenger of Allah ﷺ as saying: I forbade you to visit graves, but you may now visit them, for in visiting them there is a reminder (of death).
قَالَ رَسُولُ اللَّهِ ﷺ نَهَيْتُكُمْ عَنْ زِيَارَةِ الْقُبُورِ فَزُورُوهَا فَإِنَّ فِي زِيَارَتِهَا تَذْكِرَةً