"Then We forgave you"—meaning: the repentance that God made for them (so some of them killed themselves). Qatada said: They were commanded to commit suicide with knives, and they did so. When God had exacted His vengeance upon them, the knives fell from their hands; that was a martyrdom for the one killed and a repentance for the one who lived. "That perhaps you might be grateful"—meaning: that you might be grateful to Us.
﴿ثمَّ عَفَوْنَا عَنْكُم﴾ يَعْنِي: التَّوْبَة الَّتي جعلهَا اللَّه (لَهُم فَقتل بَعضهم نَفسه) قَالَ قَتَادَة: أمروا أَن ينتحروا بالشفار فَفَعَلُوا، فَلَمَّا بلغ اللَّه فيهم نقمته سَقَطت الشفار من أَيْديهم؛ فَكَانَ ذَلِكَ للمقتول شَهَادَة، وللحي تَوْبَة ﴿لَعَلَّكُمْ تشكرون﴾ أَي: لتشكرونا.