Qatadah (may Allah have mercy on him) said concerning this saying of Allah Almighty: "O you who believe! Retaliation has been prescribed for you in the case of those killed: the free for the free, the slave for the slave, and the female for the female" [Surah al-Baqarah: 178]: Among the people of the Jahiliyyah there was transgression and obedience to Satan. If a tribe among them had numbers and strength, and a slave of theirs was killed by the slave of another tribe, they would say: We will kill none but a free man in his place; and if a woman of theirs was killed by a woman, they would say: We will kill none but a man in her place. They considered themselves superior to others. So Allah Almighty revealed this verse, that a slave is to be killed for a slave, a free man for a free man and a woman for a woman; so abandon the wrong that you do. Then Allah Almighty revealed the verse of Surah al-Ma'idah: "And We prescribed for them therein: a life for a life, an eye for an eye, a nose for a nose, an ear for an ear, a tooth for a tooth, and for wounds retaliation." [Surah al-Ma'idah: 45].
Hadith Referenceالسنن الكبرى للبيهقي / كتاب الجنايات / 15890