Allah (SWT) states he created death in this world with his might pursuant to his wisdom by saying in his book, the All-Wise Qur'an:
"He Who created Death and Life, that He may try which of you is best in deed: and He is the Exalted in Might, Oft-Forgiving..."(al-Mulk, 67:2)
From this, it is realized that this life and death have reasons behind their creation and they are not futile and aimless. This world is a place of responsibility and deed and afterlife is a place of reckoning and reward. The religion orders this; the minds confirm this and believers believe that it is so.
The wisdom of death is hidden in the testing of human beings. Man will face the results of whatever he does, good or bad. However, this reckoning will be in the afterlife, not here. According to this explanation in the Holy Qur'an, death has a purpose defined by Allah (SWT). However, a person who lives without this consciousness in mind fears reaching Allah (SWT); he or she fears and cries out as his or relatives and friends die.
Actually, the real reason why death frightens people is its unknown nature, its preventing people from realizing their aims, and separating people from the people they love. All divine religions were sent in order to save people from this troubled situation and with the idea of "belief in resurrection after death"; and they unanimously agree on it. Moreover, the prophets' calls were about faith in Allah (SWT), then faith in the afterlife and to get ready for the afterlife.
Allah (SWT) states that it is He Who gives life and death and also states that every human's death is determined and it is with His permission. Nobody is created without a purpose and no one will be able to escape from death. Allah (SWT) states this as follows:
"Truly thou wilt die (one day), and truly they (too) will die (one day)." (az-Zumar 39:30)
Human beings who are equal in terms of death will be treated justly:
"Then shall anyone who has done an atom's weight of good, see it!, and anyone who has done an atom's weight of evil, shall see it. "(az-Zalzala 99:7,8)
In Ghazali's view, people can be classified into four categories with regard to their reactions to death:
1. The people who have not realized that life is mortal and temporary and consider that life consists of worldly desires only. According to them, death means end of enjoyment and experiencing the feared doom. The following verse from Qur'an tells about their situation:
"Say: The Death from which ye flee will truly overtake you..." (al-Jumua,62:8)
2. The people who know the outcomes of their actions and try to return to worshipping and obeying Allah by repenting. Death is a unwanted and unpleasant event for them too because they are not ready for it. Death may catch them off guard. They want to reach Allah (SWT), but they want death to delay.
3. The people who know Allah (SWT) and who are connected to Him with divine love. They push for reaching Allah (SWT) and complain about the delaying of death.
4. The people who leave affairs to Allah (SWT). For them, whatever He wants, it is to be wanted and to be liked.
What a servant needs to do is not to forget death, get ready for it and feel hopeful about the mercy of Allah (SWT). It is not appropriate to wish to die no matter how harsh the conditions are.
The truth of death is not frightening or threatening, but the beginning of the eternal life, therefore, it is unnecessary to be afraid of death. In addition, because it is only way to reach afterlife, which is a blessing in every respect, death is a blessing for us. Something that leads to a blessing is also a blessing.
Everyone, will leave this mortal world and will go to afterlife when the time determined for him or her comes. The determination is valid for everybody including prophets,. The impossibility of escaping from death is stated in the Holy Qur'an as follows:
"Every soul shall have a taste of death..." (al-Anbiya 21:35)
"Say: The Death from which ye flee will truly overtake you: then will ye be sent back to the Knower of things secret and open: and He will tell you (the truth of) the things that ye did!" (al-Jumua 62:8)
"Wherever ye are, death will find you out, even if ye are in towers built up strong and high!..." (an-Nisa 3:78)
"To every people is a term appointed: when their term is reached not an hour can they cause delay, nor (an hour) can they advance (it in anticipation)." (al-Araf 7:34)
Although this is the truth, many people forget death and cling to this world as if they will not die. In fact, recalling death, as stated in a hadith, blocks the charming effects of desires; so it decreases the love of this world and causes people to love afterlife. Every Muslim must prepare for the eternal life in this world when they have the chance. As a matter of fact, Allah (SWT) states the following in the Holy Qur'an:
"...And take a provision (with you) for the journey, but the best of provisions is right conduct. So fear Me, O ye that are wise.!"(al-Baqara 2:197)
In afterlife, people will reap what they sow in this world and see their actions. The Holy Qur'an describes the people who live however they want in the world and follow their desires as follows:
"(In Falsehood will they be) until, when death comes to one of them, he says:
"O my Lord! send me back (to life)―"In order that I may work righteousness in the things I neglected."―
"By no means! it is but a word he says Before them is a Partition till the Day they are raised up." (al-Mumenoon 23:99,100)
No one’s time of death is certain; therefore, as there are people who live consciously and prepare for death, there are also people who fall into heedlessness from time to time.
We should be ready for death by performing fard worship and avoiding sins.