These verses revealed on account of some eighty hypocrites who were excommunicated when the prophet returned from Tabuk. He forbade the believers to associate with them, and even to speak to them. Life in Medina became difficult for them, and they began to make excuses and swear by Allah in order to reconcile the believers with themselves. So these verses revealed to tell muslims how to treat them.