Yusuf Al Qaradawi: If they had gotten rid of the apostasy punishment, Islam wouldn't exist today. Islam would have ended since the death of the prophet, peace be upon him. Opposing apostasy is what kept Islam to this day.
Rashidun Caliphate Era (Apostasy War)
Wikipedia states that the first caliph, Abu Bakr, fought a defensive war against the apostates in the infant Islamic state after Muhammad's death. But hadith and alternative sources like Al Tabari imply that Abu Bakr fought an offensive war on grounds of the rebel tribes refusing to pledge allegiance to him or withholding their zakat from him.
It seem more plausible that the apostates sought secession or autonomy to govern themselves, a demand Abu Bakr felt undermined his rule. Abu Bakr himself never stated he was fighting these people for leaving Islam, still his decision became invoked by later scholars as proof that apostasy is a capital crime in Islam.
Plus, if you consider that Abu Bakr later becomes a sanctified figures in Sunni Islam, it makes sense that the scholars would approve death penalty for apostasy. I mean, what would later Muslims think of their idol if they learn he fought people for leaving Islam, whereas no where in Islamic law is this sanctioned?
So, to justify Abu Bakr and ensure his legacy remain intact, Sunni sages needed to apostasy criminalized under canon law.
Post Rashidun Caliphate Era (Abbasid Revolution)
During the Ummayad's reign of Arabia, the Shiites and Abbasids often slam them as unbelievers for not prioritizing Islam and Muslims. The Ummayads weren't hesitant in appointing non-Muslims in position of authority and didn't care to incentivise their non-Muslim subject to Islam. In fact, Ummayad's enforced polices that neutered any benefit of converting to Islam.
Now, when the Abbasids came to power, they reversed many of the Ummayad's policies in favor of Muslims, and instituted strong incentives for non-Muslims to convert. Muslims now gained more privileges and access to power and wealth over non-Muslims. The result of this is unlike in Ummayad's era, non-Muslims increasingly converted to Islam to gain certain privileges.
This mean, many of these converts were fake. They didn't believe in the Qur'anic message, but upheld the Muslim label whenever it was profitable, and as soon as the Muslim label is no longer of benefit they returned to their former faith. Apparently, the scholars came to realize this loophole and it became a challenge to overcome in order to save the future of Islam.
The scholars obviously realized they couldn't stop people from converting to Islam, and they wouldn't go back to the former Ummayad policies that did not incentivise conversion but at least kept out fake converts. Still something had to be done. And the only conceivable thing would be to a measure to scare off fake converts.
And what would be more effective in deterring these fake converts than penalizing apostasy with death?