Allah forbids His believing servants from taking the disbelievers as friends instead of the believers. This includes being friends and associates of the disbelievers, advising them, being intimate with them and exposing the secrets of the believers to them. In another Ayah, Allah said,
(Let not the believers take the disbelievers as friends instead of the believers, and whoever does that, will never be helped by Allah in any way, except if you indeed fear a danger from them. And Allah warns you against Himself). meaning, He warns you against His punishment if you fall into what He has prohibited. This is why Allah said here,
The purpose in previous verses was to point out to some ugly traits of the hypocrites, though their punishment of being in Hell with disbelievers was also mentioned as a corollary to another subject.
From this stage onwards, the purpose is to state their punishment clearly. Since the inherent effect of such impending punishment generates a sense of fear in a good-natured person which usually becomes the reason for early repentance, therefore, exemption from punishment has been promised to those who repent alongwith the incentive of good reward for them.
The Meaning of sincerity
The statement: وَأَخْلَصُوا دِينَهُمْ (Make their Faith pure for Allah) in verse 146 shows that a deed in order to be acceptable with Allah has to be free of hypocrisy and exclusively for His sake and pleasure, for Muslim jurists have enunciated the meaning of Mukhlis (translated with the weaker equivalent 'sincere' ) as follows:
A sincere person is one who acts for Allah alone and does not like that people praise him for it. (Mazhari)
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 147–148
Those who have not surrendered themselves to God succumb to worldly interests. They will associate themselves with anyone, be he religious or irreligious, by whom their worldly interests are served. Such people’s words and deeds, however religious they may appear to be, are not to please God, but to show others that they too are believers. Opportunism is their real religion, but they are at pains to show people that they are God-worshippers. These people want to prove themselves to be godly although they are not.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.