According to some Ahadith, the reason for this Hadith is that a person sent a proposal of marriage to a woman named Umm Qais, which she turned down saying that he should have to emigrate to Al-Madinah for it. Accordingly, he did it for this specific purpose, and the two were married there. On account of this event, the man came to be known among the Companions as Muhajir Umm Qais.
On the basis of this Hadith, 'Ulama' are of the unanimous opinion that the real basis of one's actions is Niyyah (intention) and everyone will be requited according to his Niyyah. It is true that Niyyah is founded in one's heart, that is to say, one has first to make up one's mind for what he intends to do and he should not express it verbally. In fact, the latter is a Bid'ah (innovation in religion) because no proof of it is found in Shariah.
The point which becomes evident from this Hadith is that Ikhlas (sincerity) is a must for every action. In other words, in every righteous deed, one should seek only the Pleasure of Allah; otherwise, it will not be accepted by Allah.