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:2:179

And there is for you in legal retribution ˹saving of˺ life, O you ˹people˺ of understanding, that you may become righteous.  

In retaliation there is life for you, that is great longevity, O people of pith, possessors of intellect, because if the would-be killer knew that he would be killed ˹in retaliation˺, he would refrain ˹from such action˺ and would have thereby given life to himself and to the one whom he had intended to kill; and so it ˹retaliation˺ was stipulated by the Law, so that you might fear killing, fearing retaliation.
القرآن:٢:١٧٩

وَلَكُمْ فِي الْقِصَاصِ حَيَاةٌ يَا أُولِي الْأَلْبَابِ لَعَلَّكُمْ تَتَّقُونَ  

{ولكم في القصاص حياة} أي بقاء عظيم {يا أولي الألباب} ذوي العقول لأن القاتل إذا علم أنه يُقتل ارتدع فأحيا نفسه ومن أراد قتله فشرع {لعلكم تتقون} القتل مخافة القود.