Allah SWA says: Pilgrimage to the House is a duty to Allah for all who can make the journey.
The scholars have explained “being able” in relation to the man owning enough money to allow him to travel and pay for the various expenses on hajj, his main needs such as food, and somewhere to stay. In the case of a woman, it is the need to have a guardian, or husband.
The scholars have differed in opinion over the blessed verse and whether hajj is legalized immediately, or when you have the means. It has been said that having the means is having extra wealth and a means to take one there (a car, plane ticket etc.) and that hajj should be done as soon as possible once one has the resources. For that reason, if a person has money that he will spend or use for his marriage, or he can complete the obligation of hajj, then this group of scholars prefer hajj over getting married, because it is supposed to be done immediately when you have the means. Some said that having the means is having a guardian, and that it is obligatory when possible, and thus, they prefer marriage over hajj.
What is most likely- and Allah knows best- is that for the person who cannot hold his desires, and whose chastity will be maintained by getting married, then in this situation it is better to get married rather than go for hajj. This is because Allah SWA has compared keeping chaste with marriage, when He said: And those who find no (means of) marriage should (exercise restraint and) keep themselves chaste until Allâh grants them means (to marry) out of His grace and bounty.