It is indeed the case that embracing Islam erases past sins. However, the scheme in question of leaving Islam and reverting to start with a clean slate is definitely flawed as:
- One may die while in a state of apostasy
- One's reverting to Islam may not be accepted
- One may become a munafiq (hypocrite)
- One's heart may be sealed against Islam
There is a risk that one dies while in a state of apostasy, and before reverting to Islam one more time. In this case, one runs the risk of not having one's sins forgiven, in addition to invalidating all previous good deeds:
يَا أَيُّهَا الَّذِينَ آمَنُوا أَطِيعُوا اللَّهَ وَأَطِيعُوا الرَّسُولَ وَلَا تُبْطِلُوا أَعْمَالَكُمْ إِنَّ الَّذِينَ كَفَرُوا وَصَدُّوا عَن سَبِيلِ اللَّهِ ثُمَّ مَاتُوا وَهُمْ كُفَّارٌ فَلَن يَغْفِرَ اللَّهُ لَهُمْ
O you who have believed, obey Allah and obey the Messenger and do not invalidate your deeds. Indeed, those who disbelieved and averted [people] from the path of Allah and then died while they were disbelievers — never will Allah forgive them.
— Qur'an 47:34
Ibn Kathir in his tafsir of this verse said that it refers to apostates who abandon Allah's guidance. In return, Allah invalidates all their previous good deeds. The companions of the Prophet ﷺ believed that no harm can befall a person who testifies that there is no diety but Allah, and no benefit can befall a mushrik (see Riyad as-Salihin » Book of Miscellany » Hadith 414) until this verse was revealed — this is when they realized that one's good deeds can be invalidated.
If one dies in a state of disbelief, previous good deeds will have been invalidated, and Allah's forgiveness will be lost. Furthermore, their repentance may not be accepted:
إِنَّ الَّذِينَ كَفَرُوا بَعْدَ إِيمَانِهِمْ ثُمَّ ازْدَادُوا كُفْرًا لَّن تُقْبَلَ تَوْبَتُهُمْ وَأُولَٰئِكَ هُمُ الضَّالُّونَ
Indeed, those who reject the message after their belief and then increase in disbelief — never will their [claimed] repentance be accepted, and they are the ones astray.
— Qur'an 3:90
While the verse that follows was revealed in connection with Bani Isra'el (believe in Mussa ﷺ, then disbelieve by worshiping the gold calf, then believing in the Torah, then disbelieving in 'Issa ﷺ, then further disbelieving in Muhammad ﷺ), it still applies to anyone in a similar condition:
إِنَّ الَّذِينَ آمَنُواْ ثُمَّ كَفَرُواْ ثُمَّ آمَنُواْ ثُمَّ كَفَرُواْ ثُمَّ ازْدَادُواْ كُفْراً لَّمْ يَكُنِ اللّهُ لِيَغْفِرَ لَهُمْ وَلاَ لِيَهْدِيَهُمْ سَبِيلاً بَشِّرِ الْمُنَافِقِينَ بِأَنَّ لَهُمْ عَذَابًا أَلِيمًا
Indeed, those who have believed then disbelieved, then believed, then disbelieved, and then increased in disbelief — never will Allah forgive them, nor will He guide them to a way.
— Qur'an 4:137
Allah warns those who repeatedly believe then disbelieve that Allah may leave them to go astray without guiding them to the right path in return for their hypcrisy. Allah may even seal over their hearts as a result of getting into the belief-disbelief cycle:
ذَٰلِكَ بِأَنَّهُمْ آمَنُوا ثُمَّ كَفَرُوا فَطُبِعَ عَلَىٰ قُلُوبِهِمْ فَهُمْ لَا يَفْقَهُونَ
That is because they believed, and then they disbelieved; so their hearts were sealed over, and they do not understand.
— Qur'an 63:3
Allah further confirms this by asking us a rhetorical question, which demonstrates that apostasy is an act of transgression:
كَيْفَ يَهْدِي اللَّهُ قَوْمًا كَفَرُوا بَعْدَ إِيمَانِهِمْ وَشَهِدُوا أَنَّ الرَّسُولَ حَقٌّ وَجَاءَهُمُ الْبَيِّنَاتُ ۚ وَاللَّهُ لَا يَهْدِي الْقَوْمَ الظَّالِمِينَ
How shall Allah guide a people who disbelieved after their belief and had witnessed that the Messenger is true and clear signs had come to them? And Allah does not guide the wrongdoing people.
— Qur'an 3:86