There is a historical background that predates Islam for the 2:178 verse.
In Sahih al-Bukhari 6881, Book 87, Hadith 20, Ibn 'Abbās narrated that this verse was revealed to abrogate a ruling that existed from the time of the Torah. For Bani Israel, the punishment for murder was only al-qisas; for Muslims: the payment of blood money became permissible. You may read more about it in Tafsir al-Tabari, Jami'a al-Bayān. Below is a brief account from his tafsir.
During the time of the Prophet ﷺ, two tribes went into war (Muqatil said those two tribes were Banu Qurayza and Banu Nadir). The war resulted in a number of casualties on both sides, and a number of prisoners of war. The stronger tribe vowed to take retribution for each one of their slaves or their women from a free member of the weaker tribe, and for each man of theirs from two men of the weaker tribe.
The two tribes of Bani Israel went to the Prophet ﷺ for arbitration. The verse in question was then revealed to the Prophet ﷺ. The translation of its meaning is:
O you who have believed, prescribed for you is legal retribution for those murdered — the free for the free, the slave for the slave, and the female for the female. But whoever overlooks from his brother anything, then there should be a suitable follow-up and payment to him with good conduct. This is an alleviation from your Lord and a mercy. But whoever transgresses after that will have a painful punishment.
— Al-Baqarah 2:178
The verse informed them of their entitlement to settle their dispute in a fair manner: a free man for a free man, a slave for a slave, etc. Retribution is not mandatory; Allah says in the same verse that "whoever overlooks from his brother anything, then there should be a suitable follow-up and payment to him with good conduct". Those who were killed with no retribution, the Prophet ﷺ ordered blood money to be paid in compensation.
When it comes to the Islamic ruling, the murdered gets punished by death, regardless of gender, slavery, etc. This is what the seera tells us was practiced during the time of the Prophet ﷺ and his companions and is also declared through this hadith:
عَنِ ابْنِ عَبَّاسٍ عَنِ النَّبِيِّ ﷺ قَالَ: الْمُسْلِمُونَ تَتَكَافَأُ دِمَاؤُهُمْ وَهُمْ يَدٌ عَلَى مَنْ سِوَاهُمْ يَسْعَى بِذِمَّتِهِمْ أَدْنَاهُمْ وَيُرَدُّ عَلَى أَقْصَاهُمْ
It was narrated from Ibn 'Abbas that the Prophet (ﷺ) said: "The blood of every Muslims is equal, they are one hand against others. The asylum offered by the lowest of them in status applies to them (all), and the return is granted to the farthest of them."
— Sunan Ibn Majah » Chapter on Blood Money » Book 21 » Hadith 2785