Slavery in islam

After studying Islam deeply, I have encountered some doubts that no one has been able to fully answer. One of these is about the issue of slavery. Slavery is permitted in the Quran, yet today it is widely regarded as immoral and inhumane. When I ask modern scholars about this, they tend to agree that slavery is wrong in today’s world. However, their explanation is that slavery was a norm at the time the Quran was revealed. But isn’t the Quran meant to be applicable for all times?

The Quran permits having sexual relationships with women "whom your right hand possesses" (female captives), but this is not something practiced today. Scholars often argue that Islam didn’t encourage slavery but instead aimed to improve the condition of slaves by teaching people to treat them kindly, clothe them, and eventually free them. Islam is also credited with gradually ending the practice of slavery.

However, my question remains: why didn’t Allah abolish slavery outright, like He did with alcohol or gambling? If Allah is all-knowing and merciful, wouldn’t He have deemed human ownership over other humans as fundamentally immoral?