A personal conjecture—Allah knows best!
The words of the noble Maryam, peace be upon her: «يَا لَيْتَنِي مِتُّ قَبْلَ هَٰذَا وَكُنْتُ نَسْيًا مَنْسِيًّا» are a kind of fervent plea for help and protection, a heartfelt supplication offered in distress. They are like the cry “Ah”—a name among the divine names—and express a plea for mercy.
It seems that through this avowal of helplessness and distress, the noble Maryam, peace be upon her, is seeking the special care and attention of the Almighty Lord. It is, in a sense, a knocking at the door of God’s special mercy—and she receives a response, for the following verse makes God’s special answer plain!
Maryam: 24 فَناداها مِنْ تَحْتِها أَلاَّ تَحْزَني قَدْ جَعَلَ رَبُّكِ تَحْتَكِ سَرِيًّا
Then a voice called to her from beneath her: “Do not grieve! Your Lord has placed a stream beneath you.”
Maryam: 25 وَ هُزِّي إِلَيْكِ بِجِذْعِ النَّخْلَةِ تُساقِطْ عَلَيْكِ رُطَباً جَنِيًّا
And shake the trunk of the palm tree towards you; it will drop fresh, ripe dates upon you.
Maryam: 26 فَكُلي وَ اشْرَبي وَ قَرِّي عَيْناً فَإِمَّا تَرَيِنَّ مِنَ الْبَشَرِ أَحَداً فَقُولي إِنِّي نَذَرْتُ لِلرَّحْمنِ صَوْماً فَلَنْ أُكَلِّمَ الْيَوْمَ إِنْسِيًّا
So eat and drink, and let your eyes be comforted. If you see anyone among the people, say by gesture: “I have vowed a fast to the Most Compassionate, so today I will speak to no one.”
An example of the prophets’ fervent appeals for help
Al-Anbiya: 83 وَ أَيُّوبَ إِذْ نادى رَبَّهُ أَنِّي مَسَّنِيَ الضُّرُّ وَ أَنْتَ أَرْحَمُ الرَّاحِمينَ
و ايّوب
And [remember] when he called upon his Lord: “Affliction and hardship have befallen me, and You are the Most Merciful of the merciful.”
Sad: 41 وَ اذْكُرْ عَبْدَنا أَيُّوبَ إِذْ نادى رَبَّهُ أَنِّي مَسَّنِيَ الشَّيْطانُ بِنُصْبٍ وَ عَذابٍ
And remember Our servant Job, when he called upon his Lord, saying, “My Lord, Satan has afflicted me with suffering and torment.”
Al-Anbiya: 87 وَ ذَا النُّونِ إِذْ ذَهَبَ مُغاضِباً فَظَنَّ أَنْ لَنْ نَقْدِرَ عَلَيْهِ فَنادى فِي الظُّلُماتِ أَنْ لا إِلهَ إِلاَّ أَنْتَ سُبْحانَكَ إِنِّي كُنْتُ مِنَ الظَّالِمينَ
And [remember] the man of the fish [Jonah], when he went away in anger, thinking that We would not constrain him. Then, from within the darkness, he cried out: “There is no god but You! Glory be to You! I was indeed among the wrongdoers!”
Al-Qasas: 24 فَسَقى لَهُما ثُمَّ تَوَلَّى إِلَى الظِّلِّ فَقالَ رَبِّ إِنِّي لِما أَنْزَلْتَ إِلَيَّ مِنْ خَيْرٍ فَقيرٌ
So Moses watered their flocks for them. Then he withdrew to the shade and said, “My Lord, I am in need of whatever good You may send down to me!”