ولقد أرسلنا من قبلك رسﻼ إلى قومهم فجاووهم بالبينات فانتقمنا من الذين أجرموا
And indeed We did send Messengers before you to their own peoples. They came to them with clear proofs, then, We took vengeance on those who committed crimes;
These are words of consolation from Allah to His servant and Messenger Muhammad. They tell him that if many of his people and of mankind disbelieve in him, the previous Messengers were also rejected, despite the clear signs that they brought, but Allah punished those who rejected and opposed them, and saved those who believed in them.
وكان حقا علينا نصر المومنين
and it was incumbent upon Us to help the believers.
This is a duty which Allah took upon Himself as a blessing and a favor to them.
This is like the Ayah,
كتب ربكم على نفسه الرحمة
your Lord has prescribed mercy for Himself. (6:54)
Ibn Abi Hatim recorded that Abu Ad-Darda', may Allah be pleased with him, said:
"I heard Allah's Messenger saying:
ما من امرء مسلم يرد عن عرض أخيه إﻻ كان حقا على الله أن يرد عنه نار جهنم يوم القيامة
No Muslim man defends the honor of his brother except that there would be a right upon Allah to defend him from the fire of Hell on the Day of Resurrection.
Then he recited this Ayah:
وكان حقا علينا نصر المومنين
and it was incumbent upon Us to help the believers.''