Sheikh Sayyed Sabiq said in his well-known book Fiqh-us-Sunnah:
There is a consensus among jurists concerning the prerequisites that must be found in a person for Hajj to be incumbent on him or her. These prerequisites are as follows:
He/she must be a Muslim.
He/she must be an adult.
He/she must be of a sound state of mind.
He/she must be free.
He/she must have the necessary power and ability to undertake the journey.
Anyone lacking any of the above conditions is not obligated to perform Hajj. All these conditions (i.e. being a Muslim, being of adult age and of sound mind, being free, and possessing the power to discharge the duty) are equally valid with respect to all other forms of worship in Islam. This is based on a hadith of the Prophet (peace and blessings be upon him) which says: “Three persons are not to be held accountable for their actions: a sleeping person until he awakes, a child until he comes of age, and a mentally disturbed person until he regains his reason.”
Freedom is an essential prerequisite for Hajj, for this worship needs time as well as financial ability. The Qur’an says: (And pilgrimage to the House is a duty unto Allah for mankind, for him who can find a way thither) (Aal `Imran 3:97).
Allah Almighty knows best.