Our theology on apostasy from the Quran is as follows:
1) It will happen, and there will be a time when the flood gates of apostasy will open. "They will leave it in droves as they entered it in droves" (Haakim).
2)They will be replaced. For every person or group that leaves Islam, Allah will bring another individual or group in their place. (Interestingly, a recent Pew study shows this.) The initial seed of iman is only from Allah, but once you have that, you can protect it and grow it with your own actions and choices.
3) There are five traits to that we should actively acquire and never lose so that Allah preserves our iman and blesses us to live and die upon the deen.
- love of Allah
- humility towards Muslims
- aloofness with rejectors of faith
- striving for the sake of the deen
- not fearing the blame of people
All of this can be found in 5:54 Ma'ida...
"You who believe, if any of you go back on your faith, then Allah will soon replace you with people He loves and who love Him, people who are humble towards the believers, hard on the disbelievers, and who strive in Allah’s way without fearing anyone’s reproach."
يَا أَيُّهَا الَّذِينَ آمَنُوا مَن يَرْتَدَّ مِنكُمْ عَن دِينِهِ فَسَوْفَ يَأْتِي اللَّهُ بِقَوْمٍ يُحِبُّهُمْ وَيُحِبُّونَهُ أَذِلَّةٍ عَلَى الْمُؤْمِنِينَ أَعِزَّةٍ عَلَى الْكَافِرِينَ يُجَاهِدُونَ فِي سَبِيلِ اللَّهِ وَلَا يَخَافُونَ لَوْمَةَ لَائِمٍ