This is because charity dispels hardships and difficulties. The fire of the wrath of Allah Ta'ala is cooled and it is protection against a bad death or death without faith (Iman). There is a Hadith in Jame' Tirmidhi:
Translation of Hadith: It has been narrated on the authority of Hadhrat Anas Bin Malik (May Allah be well pleased with him) that the Holy Prophet (Sallallahu alaihi wa sallam) said: Verily! Sadqa (Charity) dispels the anger of Allah (Subhanahu Wa Ta'ala) and saves from a death without Iman.
(Jame' Tirmidhi, Vol. 1, Pg No. 144)
Sadqa is a general word, regardless of whether an animal is slaughtered and its meat is distributed or it is cooked and fed or in some other way. All are permissible and correct. The Holy Prophet (Sallallahu alaihi wa sallam) said:
Translation of Hadith: Indeed! The Sadqa of a believer will be a shade for him (or her) on the Day of Judgment.
(Musnad Imam Ahmed, Pg No. 170)
By performing good deeds like Sadqa and the like, we become worthy of the special mercy of Allah (Subhanahu Wa Ta'ala) and we are rewarded with the "Qurb" (closeness) of Allah (Subhanahu Wa Ta'ala).
As Allah Ta'ala says in Surah A'araaf:
..........for the Mercy of Allah is (always) near to those who do good.
Surah A'araaf (7:56)
And in Surah Baqarah:
............for Allah loves those who do good.
Surah Baqarah (2:195)
When a person in any difficulty or hardship gives charity (Sadqa), then he/she is in fact treating those who receive the charity with mercy. Through this, that person receives the special mercy of Allah Ta'ala, through which difficulties and hardships ar removed.
There is a Hadith:
Translation of Hadith: Allah (Subhanahu Wa Ta'ala) treats those with special mercy who treats others with mercy.
(Abu Dawood, Jame' Tirmidhi, Pg No. 423)