Caution: Translations of Quran and Ḥadīth may lead to possible misapplications and misinterpretations. This site is intended for students of sacred knowledge that are proficient in comprehending classical Arabic and have a strong foundation in Islamic sciences. Also note that religious injunctions rely on several aspects beyond what one may glean through reading individual aḥādīth.
quran:67:2

˹He˺ who created death and life to test you ˹as to˺ which of you is best in deed - and He is the Exalted in Might, the Forgiving -  

˹He˺ Who created death, in this world, and life, in the Hereafter — or both of them in this world, since the sperm-drop is imbued with life, ˹life being˺ that ˹power˺ by which sensation becomes possible, death being the opposite of this or the non-existence of it — these being two ˹alternative˺ opinions; in the case of the latter ˹life in the Hereafter˺, ‘creation’ implies ‘ordainment’ — that He may try you, that He may test you in ˹this˺ life, ˹to see˺ which of you is best in conduct, ˹which of you˺ is most obedient to God, and He is the Mighty, in His vengeance against those who disobey Him, the Forgiving, to those who repent to Him;
القرآن:٦٧:٢

الَّذِي خَلَقَ الْمَوْتَ وَالْحَيَاةَ لِيَبْلُوَكُمْ أَيُّكُمْ أَحْسَنُ عَمَلًا ۚ وَهُوَ الْعَزِيزُ الْغَفُورُ  

{الذي خلق الموت} في الدنيا {والحياة} في الآخرة أو هما في الدنيا فالنطفة تعرض لها الحياة وهي ما به الإحساس، والموت ضدها أو عدمها قولان، والخلق على الثاني بمعنى لتقدير {ليبلوكم} ليختبركم في الحياة {أيكم أحسن عملا} أطوع لله {وهو العزيز} في انتقامه ممن عصاه {الغفور} لمن تاب إليه.