لَيْتَ expresses an unattained wish. In لَيْتَنِي, the suffix refers to “me”: “If only I…” كُنْتُ is a past-tense verb within that wish. صَاحِبِ هَذَا الْقَبْرِ forms a connected possessive expression describing the person in the grave.
The clause وَلَيْسَ بِهِ الدِّينُ إِلَّا الْبَلَاءُ connects the desperate reaction to severe affliction rather than to a noble religious aspiration.
Context matters: language reporting a desperate wish should not be mistaken for advice to seek that situation.