Praise be to Allah.
The hadeeth you mention was narrated by Imaam al-Bukhaari (may Allaah have mercy on him) in his Saheeh from Abu Hurayrah from the Prophet (peace and blessings of Allaah be upon him), who said (that Allaah said): “Vowing does not bring to the son of Adam anything that I have not already written in his Qadar (preordainments), but vowing is imposed on him by way of preordainment. Through vowing I make a miser spend of his wealth.” (Saheeh al-Bukhaari, no. 6119)
Ibn Hajar (may Allaah have mercy on him) said in his commentary on this hadeeth:
“Ibn ‘Umar said: ‘The Prophet (peace and blessings of Allaah be upon him) forbade the making of vows.’ … A clear statement prohibiting vows came in the report of al-‘Alaa’ ibn ‘Abd al-Rahmaan from his father from Abu Hurayrah, recorded by Muslim in the words ‘Do not make vows,’ and in the phrase ‘(Making vows) does not bring forward anything or delay anything [i.e., it has no effect whatsoever],’ and in the report of ‘Abd-Allaah ibn Murrah, ‘It does not change anything,’ – which is more general. A similar phrase was reported in the hadeeth of Abu Hurayrah: ‘Vowing does not bring to the son of Adam anything that I have not already written in his Qadar (preordainments)…’ Ibn al-Atheer said in al-Nihaayah: ‘The point of the hadeeth is that he told them that this thing (making vows) does not bring any immediate benefit or turn away any immediate harm, and it does not change what has been decreed. Thus he said, Do not make vows, as you know that you cannot get, or turn away, anything by means of vows that Allaah has not already decreed for you. If you make a vow then fulfill it, because whatever you have vowed becomes obligatory for you.’ (Then Ibn Hajar quotes the opinions of a number of scholars on the reason why making vows is prohibited): … The reason may be that the person who makes a vow does not do so in order to draw closer to Allaah, but will only do so if he gets what he wanted, as if this is an exchange, which corrupts his intention to draw closer to Allaah. This interpretation is indicated by the words, ‘It does not bring any good,’ and ‘Vowing does not bring to the son of Adam anything that I have not already written in his Qadar (preordainments).’ This is a clear statement as to why vows should not be made. The phrase ‘it does not bring any good’ means that the end result will be no good, and it might be too difficult to fulfil the vow, or it might mean that (the vow) will not bring about good if it has not been decreed for him…. Al-Nawawi said: ‘The phrase “it does not bring any good” means that it will not stop anything that has already been decreed, as is clear from the other reports.’ … (Then Ibn Hajar quotes from Ibn Daqeeq al-‘Eed), saying that he described the difference between nadhr al-mujaazaah (vow of repayment, one in which an act of worship is promised in return for a favour), which is forbidden, and nadhr al-ibtidaa’ (vow of initiative, where one does the promised act of worship first, without waiting to see if the favour is granted or not), which is a pure act of worship.”
In al-Mufahhim, al-Qurtubi confirmed the idea that the ahaadeeth forbid nadhr al-mujaazaah: ‘This refers to a situation where a man might say, for example, “If Allaah heals this person who is sick, I will give such-and-such in charity.” The reason why it is disliked is that he postpones doing the act of worship mentioned, and makes it conditional upon getting the desired result. This makes it quite clear that he does not have the sincere intention of drawing closer to Allaah, because he has clearly stated that his approach is that of giving something in return for something. It is quite clear that if the sick person is not healed, he will not give the charity which is conditional upon the sick person’s recovery. This is the attitude of the miser, who does not give anything of his wealth except in exchange for some immediate return, usually something that is worth more than what he is prepared to give. This is what is referred to in the hadeeth: “Through vowing I make a miser spend of his wealth.” To this could be added the point that there is an ignorant belief that making a vow guarantees that one will get the desired result, or that Allaah will do what a person wants because of the vow. Both notions are addressed in the hadeeth: “Vowing does not bring to the son of Adam anything that I have not already written in his Qadar (preordainments).”’ Concerning the aayah (interpretation of the meaning): “They (are those who) fulfil (their) vows…” [al-Insaan 76:7] al-Tabaraani reported with a saheeh isnaad that Qutaadah said: “They used to vow to do acts of worship such as praying, fasting, giving zakaat and going on pilgrimage (Hajj and ‘Umrah), and other acts which were obligatory for them, and so Allaah called them abraar (those who are pious, fear Allaah, and avoid evil – see al-Insaan 76:5). It is clear that it is not those who make vows of repayment (nadhr al-mujaazaah) who are praised…”
Al-Baydaawi said: “People usually make vows conditional upon gaining some benefit or removing some evil, and this is forbidden because it is the way of the miser. If a generous person wants to draw closer to Allaah, he starts doing good deeds straight away, but the miser would never voluntarily give anything except in return for something which he is given first. This attitude will not protect him from anything that has already been decreed, or bring him any good thing that has not been decreed for him. The vow will be in accordance with qadar and will make him give something that he would not have given otherwise… And Allaah knows best.”