In the Name of Allah, the Most Gracious, the Most Merciful.
The Case of the Hypocrites and their Behavior
Allah the Exalted states that the hypocrites pretended to be Muslims when they went to the Prophet . In reality, they were not Muslims, but rather the opposite. This is why Allah the Exalted said,
(When the hypocrites come to you, they say: "We bear witness that you are indeed the Messenger of Allah.") meaning, `when the hypocrites come to you, they announce this statement and pretend to believe in it.' Allah informs that there is no substance to their statement, and this is why He said,
The incident, in which this Surah was revealed, took place in the campaign against Banul-Mustaliq which happened, according to Muhammad Ibn Ishaq in Sha’ ban 6AH and according to Qatadah and ‘Urwah, in Sha’ ban 5AH. [ Mazhari ] According to Muhammad Ibn Ishaq and most historians, the details of the incident is as follows: The Messenger of Allah received the news that the leader of Banul-Mustaliq, name, Harith Ibn Dirar, is preparing for a campaign against him Harith Ibn Dirar was the father of Sayyidna Juwairiah ؓ who later on embraced Islam and became one of the Holy wives of the Holy Prophet ﷺ . Harith Ibn Dirar ؓ himself later on embraced Islam.
When a man embraces the faith, he makes a sincere vow. Thereafter, different practical occasions arise in life when he is required to act according to his vow. Now, one who, on such occasions, hears the voice of his heart and fulfils the requirements of his vow, has in effect revived and confirmed his vow of faith. On the contrary, one who hears his inner voice, ignores it and acts in breach of his vow, will gradually become less and less conscious of his vow and will eventually become completely insensitive about his vow of faith. This, in fact, is the meaning of ‘their hearts are sealed up’.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.