Hajj literally means 'to set out for a place'. Islamically however it refers to the annual pilgrimage that Muslims make to Makkah with the intention of performing certain religious rites in accordance with the method prescribed by the Prophet Muhammad (saws).
Hajj and its rites were first ordained by Allaah in the time of the Prophet lbraaheem [Abraham] (AS) and he was the one who was entrusted by Allaah to build the Ka'ba - the House of Allaah - along with his son Ismaa'eel [Ishmael] at Makkah. Allaah described the Ka'ba and its building as follows:
"And remember when We showed Ibraaheem the site of the [Sacred] House [saying]: Associate not anything [in worshipi with Me and purify My House for those who circumambulate it [i.e. perform tawaaf] and those who stand up for prayer and those who bow down and make prostration [in prayer etc.]."
[Surah Al-Hajj 22:26]
After building the Ka'ba, Ibraaheem (AS) would come to Makkah to perform Hajj every year, and after his death, this practice was continued by his son. However, gradually with the passage of time, both the form and the goal of the Hajj rites were changed. As idolatry spread throughout
During the Hajj period itself, the atmosphere around the sacred precincts of the Ka'ba was like a circus. Men and women would go round the Ka'ba naked, arguing that they should present themselves before Allaah in the same condition they were born. Their prayer became devoid of all sincere remembrance of Allaah and was instead reduced to a series of hand clapping, whistling and the blowing of horns. Even the talbeeyah  was distorted by them with the following additions: 'No one is Your partner except one who is permitted by you. You are his Master and the Master of what he possesses'.
Sacrifices were also made in the name of God. However, the blood of the sacrificed animals was poured onto the walls of the Ka'ba and the flesh was hung from pillars around the Ka'ba, in the belief that Allaah demanded the flesh and blood of these animals.
Singing, drinking, adultery and other acts of immorality was rife amongst the pilgrims and the poetry competitions, which were held, were a major part of the whole Hajj event. In these competitions, poets would praise the bravery and splendour of their own tribesmen and tell exaggerated tales of the cowardice and miserliness of other tribes. Competitions in generosity were also staged where the chief of each tribe would set up huge cauldrons and feed the pilgrims, only so that they could become well-known for their extreme generosity.
Thus the people had totally abandoned the teachings of their forefather and leader Ibraaheem (AS). The House that he had made pure for the worship of Allaah alone, had been totally desecrated by the pagans and the rites which he had established were completely distorted by them. This sad state of affairs continued for nearly two and a half thousand years. But then after this long period, the time came for the supplication of Ibraaheem to be answered:
"Our Lord! Send amongst them a Messenger of their own, who shall recite unto them your aayaat (verses) and instruct them in the book and the Wisdom and sanctify them. Verily you are the 'Azeezul-Hakeem [the All-Mighty, the All-Wise]."
[Surah Al-Baqarah 2:129]
Sure enough, a man by the name of Muhammad ibn 'Abdullaah (SAWS) was born in the very city that Ibraaheem (AS) had made this supplication centuries earlier. For twenty-three years, the Prophet Muhammad (SAWS) spread the message of Tawheed [true monotheism] - the same message that Ibraaheem and alI the other Prophets came with - and established the law of Allaah upon the land. He expended every effort into making the word of Allaah supreme and his victory over falsehood culminated in the smashing of the idols inside the Ka'ba which once again became the universal centre for the worshippers of the one True God.
Not only did the Prophet rid the Ka'ba of all its impurities, but he also reinstated all the rites of Hajj which were established by Allaah's Permission, in the time of Ibraaheem (AS). Specific injunctions in the Qur'aan were revealed in order to eliminate all the false rites which had become rampant in the pre-Islamic period. All indecent and shameful acts were strictly banned in Allaah's statement:
"There is to be no lewdness nor wrangles during Hajj."
[Surah al-Baqarah 2:197]
Competitions among poets in the exaltations of their forefathers and their tribesmen's' achievements were all stopped. Instead, Allaah told them:
"And when you have completed your rites [of Hajj] then remember Allah as you remember your forefathers; nay with a more vigorous remembrance."
[Surah al-Baqarah 2:200]
Competitions in generosity were also prohibited. Of course, the feeding of the poor pilgrims was still encouraged as this was done in the time of Ibraaheem (AS) but Allaah commanded that the slaughtering of the animals which was done for this purpose should be done seeking the pleasure of Allaah rather than fame and the praise of the people. He said:
"So mention the name of Allaah over these animals when they are drawn up in lines. Then, when they are drawn on their sides [after the slaughter], eat thereof and feed the beggar who does not ask, and the beggar who asks."
[Surah al-Hajj 22:36]
As for the deplorable practice of spattering blood of the sacrificed animals on the walls of the Ka'ba and hanging their flesh on alters, then Allaah clearly informed them that:
"It is neither their meat nor their blood that reaches Allaah, but it is Taqwaa (piety) from you that reaches Him."
[Surah al-Hajj 22:37]
The Prophet (SAWS) also put a stop to the practice of circling the Ka'ba in a state of nudity and the argument that the pagans put forward to justify this ritual was sharply rebutted in Allaah's question:
"Say: Who has forbidden the adornment [i.e. clothes] given by Allaah which He has produced for His Slaves?"
[Surah al-A'raaf 7:32]
Another custom which was prohibited through the Qur'aan was that of setting off for Hajj without taking any provisions for the journey. In the pre-Islamic period, some people who claimed to be mutawakkiloon (those having complete trust in Allaah) would travel to perform Hajj begging food the whole journey. They considered this form of behaviour a sign of piety and an indication of how much faith they had in Allaah. However Allaah told mankind that to have sufficient provisions for the journey was one of the preconditions for making Hajj. He said:
"And take a provision [with you] for the journey, but the best provision is at-Taqwaa (piety)."
[Surah al-Baqarah 2:197]
In this way, all the pre-Islamic practices, which were based in ignorance, were abolished and Hajj was once more made a model of piety, fear of Allaah, purity, simplicity and austerity. Now, when the pilgrims reached the Ka'ba, they no longer found the carnivals and the frolic and frivolity that had once occupied the minds of the pilgrims there before. Now, there was the remembrance of Allaah at every step and every action and every sacrifice was devoted to Him alone. It was this kind of Hajj that was worthy of the reward of paradise, as the Prophet (SAWS) said: "The reward for an accepted Hajj is nothing less than paradise." 
May Allaah grant us all the ability to visit His House and perform the Hajj in the manner of the Prophet Muhammad (SAWS). Aameen.