And what [harm would come] upon them if they believed in Allāh and the Last Day and spent out of what Allāh provided for them? And Allāh is ever, about them, Knowing.
Allah chastises the stingy behavior of those who refuse to spend their money for what Allah ordered them, such as being kind to parents and compassionate to relatives, orphans, the poor, the relative who is also a neighbor, the companion during travel, the needy wayfarer, the slaves and servants. Such people do not give Allah's right from their wealth, and they assist in the spread of stingy behavior. The Messenger of Allah ﷺ said,
«وَأَيُّ دَاءٍ أَدْوَأُ مِنَ الْبُخْل»
(What disease is more serious than being stingy) He also said,
Previous verses carried the condemnation of those who refused to believe in Allah and in the Akhirah and were miserly. The present verses persuade people to believe in Allah and the Akhirah and engage in the gainful activity of spending in the way of Allah. Then, towards the end (41-42), a description of the trying situations prevailing on the plains of Resurrection appears to warn people, who refuse to believe and refuse to do what is good, of their evil end.
Commentary
In the first verse (39): وَمَاذَا عَلَيْهِمْ لَوْ آمَنُوا بِاللَّـهِ it is said: What conceivable harm could have affected them if they had believed in Allah and the Last Day and spent out of what Allah had given them? at is so tough, difficult or frightening about it? All these are as easy as they come. Going by them, taking to them and believing in them does not hurt or harm or cause any inconvenience. Why then, would someone elect to be disobedient, the certain outcome of which is nothing but disaster in the Akhirah?
Tazkirul Quran
Maulana Wahiduddin KhanOn ayahs 37–39
Whatever man possesses is provided by God. This reality demands that man should surrender himself to God and become His worshipper. Such a person naturally becomes humble and his humility is expressed in his relations with the other human beings interacting in his life. He behaves decently with his mother and father and feels the watchful presence of God while dealing with all those who come into contact with him. He pays everybody’s due in accordance with his relationship and need. To overlook a person, in whatever capacity he has to deal with him, appears to him as if he himself is taking the risk of being overlooked by God. One who does not surrender to God, develops an overweening sense of pride. He thinks that whatever he possesses is the outcome of his labour and intelligence. Consequently, he considers that his earnings belong to him alone. To become associated with poor relatives and destitutes becomes a matter of degradation for him. He spends lavishly to satisfy his desires and serves his own interests, but becomes mean about such expenditure as does not satisfy his ego. He is very generous in matters which give him publicity, but quite a miser in the case of unpublicized religious causes.
Uthmani text of the Madinah mushaf (King Fahd Complex). Translation: Saheeh International. Tafsir via Quran.com.