Saad Ibn Abdillah al-Ashari al-Qummi (r.a.) narrates:
Once I got into a debate with a deeply bigoted Nasibi. During the debate he said: ‘Death be on you and all your co-religionists. You Rafizis curse the immigrants (muhajireen) and helpers (ansar) and deny their love for the Holy Prophet (s.a.w.a.). While the ‘Siddeeq’ was the most exalted of persons among the companions and he had ‘precedence in accepting Islam’. Don’t you know that the Messenger of Allah (s.a.w.a.) took him along to the cave on the night of migration (Hijrah) due to the risk to his life (i.e. Abu Bakr), just as he was concerned for his own safety. Because he (s.a.w.a.) knew that he would be his caliph and successor. Therefore he wanted to protect his life like he was concerned about his own security. So that the religion may not be destroyed after him.
In those very circumstances he made Ali (a.s.) sleep on his bed as he knew that even if he were killed there would be no problem for Islam in the future because there were people among the companions who could have taken his place, therefore he did not accord much importance to his (Ali) getting killed.
Saad could not give effective replies so he goes to the house of Imam Hasan Askari (a.s.) in Samarra for answers to this and other questions.
Imam Mahdi (a.t.f.s.), who was only a child then, addresses Saad:
O Saad, your opponents claim that the Holy Prophet (s.a.w.s.) took with him the selected one of this nation to the cave as he was afraid for his safety in the same way as he was worried about his personal security because he (s.a.w.a.) knew that he (Abu Bakr) would be the ‘caliph’ of the nation after him.
As for Ali (a.s.) he made him sleep on his bed as he knew that the vacuum created by the death of Abu Bakr will not be as big as the one on death of Ali (a.s.) because there were others who could fill that vacuum.
You can reply by asking him that are you not having the belief that the Holy Prophet (s.a.w.s.) said: After me the caliphate shall be for thirty years. And they apply it to the tenures of the four persons, Abu Bakr, Umar, Usman and Ali (a.s.). The opponent will have to agree. Tell him if this is correct, why did he take only one caliph, Abu Bakr, to the cave, leaving the other three. This shows that the Prophet considered them unimportant since it was necessary that he acts with them all like he did with Abu Bakr. Since he did not do it, he considered their rights unimportant and he discriminated between them in his kindness to them while it was necessary for him to have the same concern for all of them.
Al-Ehtejaaj v 2 p 465
Behaar al-Anwaar v 30 p 184-185