يَا لَيْتَنِي كُنْتُ مَكَانَ صَاحِبِ هَذَا الْقَبْرِ reports the words of a profoundly distressed person. It shows how a severe trial may affect someone.
A statement appearing within a hadith is not necessarily an instruction to imitate it. A sound response is patience, seeking help, finding practical support, and treating distressed people compassionately.
Example: If someone is overwhelmed by financial or family hardship, listen without ridicule, help them remain safe, and connect them with trusted people who can assist.