According to a 12er shia website here are the reasons:
1) He unlike the previous 11 Imams did not want to give Bayah to the rulers
2) To test the 12ers
3) Fear of his Death
4) The hypocrisy of the 12ers
Reasons for the Occultation of Imam Mahdi (A.S.)
1. Free from Allegiance of Every Tyrant
Amirul Momineen Alt (A.S.) said,
"Certainly', when the Qaem from among us shall arise, he will not have the allegience of any one upon his neck. It is for this reason that his birth is secret and his person is in Ghaibat."
(Kamaaluddin Vol.1. Pg.303)
It must be mentioned that all of our Imams had to pledge allegience to every tyrant ruler except for a short period during the rule of Umar ibne Abdul Aziz. This was because, on the face of it, it would seem that they are not against the ruler, In this way they could protect Islam. In the absence of popular support, the Imams were left alone and thus they entered into an understanding with the rulers. Thus even Imam Husain (A.S.) for a particular period did not find it necessary to revolt against the regime of Muawiya.
In this regard Hazrat Mahdi (A.S.) says:
"Verily each of my ancestors had the oath of allegience, upon their necks, of their contemporary tyrant rulers. But I will reappear at such a time that I will not have any tyrant's allegience upon my neck."
(Ghaibat Tusi Pg.292, Kamaaluddin VoL2. Pg.485)
2. Test Of The People
Imam al Kazim (A.S.) said,
"My son ! when the fifth descendant of the seventh of the Imams is not visible to you ! It is when Allah will test your belief. Ghaibat is inevitable for the Master of this affair. Till the time when the religion is completely transformed, and only a few people will have belief in him. My son ! That Ghaibat, It is a
trial through which Allah, the Almighty tests His servants."
(Ghaibat-e-Toosi Pg.166 & 337. Al Kafi vol.1 Pg.336. Kamaaluddin vol.2 Pg.359 and 360. Kifayatul Asar Pg.264-265)
3. Fear of the Enemy
Imam Musa al-Kazim (A.S.) said,
"The Qaem is the one who will purify the earth from the enemies of Allah, the High and the Mighty. And he will fill the earth will justice and equity just as it is filled with injustice and tyranny. He is the fifth of my descendants. He will go into occultation due to the fear of his own (life)."
(Kamaaluddin vol.2 Pg.361. Kifayatul Asar Pg.265-266)
According to common sense it is necessary for man not to throw away his precious life without a legitimate aim. Thus, the prophets (A.S.) and the Imams (A.S.) have taught the people that it is their duty to protect their life under every circumstance and should never put their life in danger. Therefore it is the duty of the last of these exalted personalities to protect himself till the time of his reappearance when he will establish the new world order.
4. Weakness and Lack of Co-operation of the People.
Imam Mahdi (A.S.) said.
"If our shias; may Allah help them in His obedience; would have fulfilled their covenant with united hearts then there would have. been no delay in our meeting, and they would have been blessed with our visitation at the earliest, along with the recognition of truth and confirmation of our rights."
(Al Ihtejaj vol.2 Pg.602)
http://www.imamreza.net/eng/imamreza.php?print=4589Also here are some more ahadith from Bihar al Anwar which state the same reasons.
Ghaibat Nomani:
It is narrated from Ahmad bin Idris from Ibne Qutaibahfrom Ibne Shazan from Ahmad bin Abi Nasr Bazanti that he said: Imam Musa Kazim(a.s.) said:
“By Allah, that to which you look forward to, will not come about exceptafter you are distinguished and you are subjected to a test till except for a few,none of you Shia will remain… then he recited the following verses:
“What! do you think that you will be left alone while Allah has not yet known those of you who have struggled hard and have not taken anyone asan adherent besides Allah and His Apostle and the believers…” (SurahTaubah 9:16)
Shaykh Saduq has narrated from his father from Himyari from his chains of narrators directly from Ali bin Yaqtin that he said:
I asked Imam Musa Kazim (a.s.): “How come the predictions about youare never fulfilled whereas all the predictions about your opponents are fulfilled?”He said: “The predictions about our enemies, since they are true they arefulfilled. And with regard to us it is not predictions; on the contrary they are your aspirations and hopes. Thus their result is obvious.”