If a donor is capable of doing both—that is, giving money for Hajj to those who are financially incapable of performing it and giving money in charity to the poor, the needy, and the insolvent debtors—in this case providing the means for Hajj is better. However, if a person wants to do one of the two or if he or she is incapable of doing both, spending money in charity is worthier than facilitating Hajj for others. This is according to the jurisprudence of priority as regards the acts of worship.
Dr. `Ugail Jasem An-Nashmi, professor of Shari`ah at the University of Kuwait, states the following: There are two aspects in this issue: the money giver and the money receiver for Hajj. One who is asked to accept a certain sum of money from a charity organization that acts on behalf of the donor does not have to take the money, as the Lawgiver (Allah) does not oblige one to do so. The Lawgiver does not ask Muslims to overexert themselves in order to have the means to perform Hajj. Moreover, the obligation to take the money might be considered a favor done for one, in which case one does not have to accept and is not considered financially able to perform Hajj. This is Imam Ahmad ibn Hanbal’s opinion. As for Ash-Safi`i, he said, “If one is given what makes one able to perform Hajj, one must perform it, as one is then able to perform it financially without being regarded as accepting a favor of anybody, or being exposed to any harm. So Hajj has become incumbent upon one.”

Thus, the preponderant view here is that one does not have to accept such money if there will be a kind of favor done for one, or the like. If not, which differs from one person to another, and one has received the money, one must perform Hajj.
As for the person who gives money as charity for people to perform Hajj for themselves and not on his behalf, this is a good deed for which he will receive reward from Allah the Almighty, in sha’ Allah.. But as regards preference, if the donor is able to combine giving money for others to perform Hajj and spending money in charity, doing both is the best. However, if the donor intends to do one of the two, or if he is incapable of doing both, then priorities should be considered: Spending money in charity ways is worthier than facilitating Hajj for others.
The following accounts support this view:
Abu An-Nasr At-Tammar narrated that a man came to say farewell to Bishr ibn Al-Harith before traveling for Hajj. He said, “I have decided to perform Hajj; what do you order me to do? Bishr asked, “How much money have you prepared for the expenses?” The man answered, “Two thousand dinars.” Bishr asked, “What do you seek with your Hajj? Is it for being ascetic or because of yearning for the House or seeking Allah’s pleasure?” The man answered, “Seeking Allah’s pleasure.” Bishr again asked, “If you are able to win Allah’s pleasure without leaving your country, spending the two thousand dinars and being sure of winning the pleasure of Allah Almighty, will you do so?” The man answered, “Yes.” On that Bishr said, “Go and give the money to ten people like an insolvent debtor to pay his debt, a poor man to improve his conditions, a breadwinner to support his dependents adequately, and one raising an orphan raiser to make the orphan happy. If you have a strong will to give all the money to only one person, do so, for bringing happiness to a Muslim’s heart, relieving the sufferer, doing away with harm and helping the weak is better than performing Hajj a thousand times after the obligatory Hajj of Islam. Get up and spend your money the way I told you” (Al-Ghazali in Ihya’ `Ulum Ad-Din, vol. 3, p. 397).
It is also narrated that `Abdullah ibn Al-Mubarak set out for Hajj once and crossed a number of countries on his way. Then, one of their birds died, so he ordered that it be thrown in a garbage dump. After that, his companions preceded him. When he passed by the garbage dump, he saw a girl coming out from a nearby house, taking the dead bird and hurrying back to the house. Ibn Al-Mubarak approached her and asked about her condition and about her taking the dead bird. At first she was too shy to answer, then she said, “My mother and I do not have anything except this waist wrapper. We have no food except what is thrown in this garbage dump. I had a father who had great wealth but his wealth was taken and he was killed for some reason. We are left nothing to eat or sustain ourselves with.” On hearing this, Ibn Al-Mubarak’s eyes were filled with tears. He ordered that the loads and supplies of Hajj be returned, then he asked his deputy, “How much money do you have?” He answered, “A thousand dinars.” On that Ibn Al-Mubarak said, “Leave twenty dinars for our return and give the rest to this distressed woman for, by Allah, I was tormented to know her calamity. This is better to Allah than our performance of Hajj this year.” Then he went back and did not perform Hajj.