You'd have to look at historical context as well. First of all, there were a large power vacuum when the Prophet Muhammad died, leading to the Ridda wars. This was a clear attempt by apostates and other false prophets to gain power.
Apostasy contributed very strongly to national instability at this point, as well as a lot of killings and torture upon Muslims.
While this did not occur during the lifetime of the Prophet, some scholars argue that the Prophet foresaw the troubles that apostates would cause immediately after his death and this was what the hadith meant.
Wikipedia article on Ridda wars
The Biography of Abu Bakr As-Siddeeq by Dr. 'Ali Muhammad Muhammad As-Sallabee does a very good coverage of this too.
Second, Muslims were offered substantial benefits, such as the trust to serve in the military, thus gaining war booty, as well as other benefits. They were also given some political status to hold certain government offices, though this varied between the different Caliphates, more so in the later ones than the earlier ones.
A non-Muslim under many caliphates were required to pay a Jizya tax.
Non-Muslim men must pay a nominal tax called Jizya that gives them full citizenship rights, exempting them from National Service and taxes specific to Muslims like zakat . Jizya is means tested and there are different bands for different levels of wealth. Caliph Omar imposed three bands for the Jizya tax - 4 dinars (£108) for the rich, 2 dinars (£54) for the middle class and 1 dinar (£27) for the poor. The Jizya tax rate is much lower rate than that of zakat , t herefore the tax burden of non-Muslims is lower than that of Muslims in the Caliphate. (caliphate.co.uk)
What many Muslims who support the apostasy death penalty conveniently forget to mention today was that a death penalty was also applied to those who refused to pay the Zakat.
Both al-Bukhari, in "The Book of Calling the Apostates to Repent" in "The Chapter on Killing those who Refuse to Accept the Obligatory Laws and those Associated with Apostacy"; and Muslim, in "The Book of Faith" in "The Chapter on the Order to Fight People", report, on the authority of Abu Hurayra, who said:
"After the Prophet had died, and Abu Bakr was made his successor, there were [some] Arabs who turned to disbelief. 'Umar said: 'O Abu Bakr! How can you fight the people when the Prophet of Allah (S.A.W.) has said: 'I have been ordered to fight the people until they say: 'There is no God but Allah' and whoever says this, makes himself and his property inviolable except by legal right, and his reckoning is with Allah?' Abu Bakr replied: 'By Allah! I will fight whoever differentiates between salat and zakat , for zakat is a lawful right upon the property! By Allah! Were they to withhold even a single animal that they used to give the Prophet of Allah (S.A.W.), I will fight them over their withholding it'. Then 'Umar said: 'By Allah! I saw then that Allah had opened the heart of Abu Bakr to [the cause of] fighting, and I realized then that it was correct". (momin.com)
As quoted, this death sentence was further supported by the right to sentence an apostate to death. It's an economical move, and was done to prevent people converting in and out of Islam as a tax loophole.
So, it applies mainly for economical and political purpose. Even more so, because people identified themselves by religion more than by nationality back then. Joining a religion then exiting was akin to gaining citizenship then dropping it, which many leaders would consider treason.
The "no compulsion in religion" verse is often cited in the sense that forcing someone to join Islam does not make the conversion valid.