Sensing the need of the poor person and treating him kindly come under the heading of piety, for the attaining of which fasting was prescribed
Praise be to Allah
Allah does not prescribe anything but for a wise reason, whether people are aware of it or it is hidden from them, or they know part of it and part of it is hidden from them. Allah has great wisdom that human minds cannot comprehend.
Allah, may He be exalted, has mentioned the wisdom behind the prescription and obligation of fasting in the verse in which He says (interpretation of the meaning):
“O you who believe! Observing As-Saum (the fasting) is prescribed for you as it was prescribed for those before you, that you may become Al-Muttaqoon (the pious)”
Some of the scholars have stated that one of the issues of piety that fasting encourages is so that the rich person will come to understand the situation of the poor person, and how he suffers from hunger and need, so that this will motivate him to treat him kindly and meet his brother’s needs. This is part of piety.
Taqwa (translated here as piety) is a general term which includes doing all that is good and refraining from all that is evil. Ibn Katheer (may Allah have mercy on him) said:
Taqwa (piety) is a general term which includes doing all acts of obedience and refraining from all evils.
End quote from Tafseer Ibn Katheer (1/492)
Shaykh Ibn ‘Uthaymeen (may Allah have mercy on him) said:
Taqwa (piety) is a general term which includes doing all that Allah has enjoined and refraining from all that He has forbidden, because the word is derived from wiqaayah (protection); what it means is taking measures to protect oneself from the punishment of Allah, and there is no way to protect oneself from the punishment of Allah except by doing that which He has enjoined and refraining from that which He has prohibited.
End quote from Majmoo‘ Fataawa wa Rasaa’il al-‘Uthaymeen (24/40).
There is no text in the Holy Quran or in the Prophetic Sunnah that specifically indicates that Allah, may He be exalted, has enjoined fasting on us so that we may feel empathy with the poor. But those scholars who mentioned that based it on the idea that this is included in the general meaning of piety, which the Holy Qur’an states is the wisdom behind fasting, and suggested that this is appropriate in the case of one who is fasting, because it is known that Islamic teaching encourages helping others and creating mutual love and compassion among the believers.
As-Sa‘di (may Allah have mercy on him) said:
Allah, may He be exalted, tells us of the wisdom behind the prescription of fasting, as He says “that you may become Al-Muttaqoon (the pious)”. Fasting is one of the greatest means of developing piety, because it involves obeying the command of Allah and avoiding that which He has forbidden.
Part of the piety that fasting involves is that the fasting person refrains from that which Allah has forbidden to him of food, drink, intercourse and so on, to which he is naturally inclined, seeking thereby to draw closer to Allah, hoping for His reward by giving up these things. This is part of piety. Piety also includes the following:
The fasting person trains himself to remember that Allah, may He be exalted, is always watching, so he gives up things that he desires even though they may be available to him, because he knows that Allah is watching him.
The fasting person usually does many acts of worship and obedience, which are characteristics of piety.
By fasting, the rich man feels the pain of hunger, which makes him inclined to help the poor and destitute. This is also a characteristic of piety.
End quote from Tafseer as-Sa‘di (p. 86)
Shaykh Muhammad al-Mukhtaar ash-Shinqeeti (may Allah preserve him) said:
In fasting there is much good, because it reminds the rich of the poor and needy. If a person feels hunger and thirst, even though he knows that at the end of the day he will be able to find food and drink, he will remember the poor who do not find any food or drink, hence they said that in this fast there is a great deal of good for the individual, as it reminds him of the weak, especially if he is one of the rich and wealthy.
The rich man may forget his brethren among the weak and poor because of the wealth that he has, as Allah, may He be exalted, says (interpretation of the meaning):
“Nay! Verily, man does transgress all bounds (in disbelief and evil deed, etc.).
Because he considers himself self-sufficient”
If a person feels himself to be self-sufficient, he will become arrogant, but if he feels hunger as the poor feel hunger, and he feels thirst as the poor feel thirst, that will motivate him to remember these weak ones and show compassion towards them. End quote.
Sharh Zaad al-Mustaqni‘ (7/100)
Therefore we fast as an act of worship to Allah, may He be exalted, and in obedience to Allah and His Messenger (blessings and peace of Allah be upon him), so that we may attain piety and fear of Allah in our hearts, which leads to happiness in both realms (this world and the hereafter). And part of piety is feeling empathy for the poor, which will motivate us to help them.
See also question no. 26862
And Allah knows best.