As a fact, if a society is not in harmony, with joined hearts, united in rank and word in addition to a shared goal, it cannot achieve victory.
(وَأَلَّفَ بَيْنَ قُلُوبِهِمْ) (And He brought together their hearts.): The term (brought together) denotes gathering and unity. Before Islam, the tribes used to wage war with each other for any small cause such as a camel and even a single line of poetry. In fact, there was animosity among the tribes, and significant division prevailed. Allah (swt) is saying to the Prophet (saws) that neither you (O’ Muhammad), nor any other human can join the hearts of these divided people.
(لَوْ أَنفَقْتَ مَا فِي الْأَرْضِ جَمِيعًا مَّا أَلَّفْتَ بَيْنَ قُلُوبِهِمْ) (If you had spent all that is in the earth, you could not have brought their hearts together): Anything on the earth can influence anything except for the hearts. You cannot give a person a large amount of money and say, “Love me,” because love cannot be bought or sold. If someone pretends to love, you still cannot affect his heart.
(وَلَٰكِنَّ اللَّهَ أَلَّفَ بَيْنَهُمْ ۚ) (but Allah brought them together,): Hearts are in the hands of Allah, as the Messenger of Allah (saws), said:
” The hearts of all men are between two of the Compassionate’s fingers as if they were one heart which He turns about as He wills.”[1]
[1]Sahih Muslim: The Book of Decree, Chapter: Allah’s Direction of the Hearts However He Wills, Hadith no. 2654