What is the ruling of Hajj in Islam?
The worship of Hajj is fard (obligatory) for each Muslim who can afford
"And perform properly the Hajj and 'Umrah for Allah." (Baqarah, 196)
"O people! Allah (swt) had ordained fard the worship of Hajj. Hurry to perform the Hajj." (Muslim)
Hajj (pilgrimage) is one of the pillars of Islam. So, it's an order of Allah (swt) that is fard like prayer and fasting.
It is narrated from Ibn Omar that the Holy Prophet (pbuh) said:
(The superstructure of) al-Islam is raised on five (pillars), to know and believe without suspicion, as if witnessed that there is no God but Allah, and Muhammad is his servant and messenger, the establishment of prayer, payment of Zakat, the, fast of Ramadan, Pilgrimage (to Mecca). (Bukhari, Muslim, Tirmidhi, Nasai)