This part is taken from Yoga Vasishtam in “Spiritual Stories” as Told by Ramana Maharshi

In the Vasishtam it is stated that Rama, after his return from a pilgrimage, found that the whole world was full of misery and that bearing the body was itself a cause of misery. He, therefore left everything, even things like eating and drinking, and remained motionless. When Viswamitra asked Dasaratha to send Rama to guard his oblations ceremony (yagna), Dasaratha said that Rama was like a mad man and described some of the signs of his madness. On hearing them, Viswamitra said that he was very pleased to hear of those symptoms, that such madness did not come to many people and that he would like to see him and asked for him to be brought. Rama accordingly came, prostrated before all those present and sat down.

Viswamitra saw him and asked him the cause of his madness, and addressing Vasishta, said, “Please teach Rama the knowledge of the Self, the knowledge which Brahma taught you and me.” Vasishta agreed to do so. While he was teaching, siddhas from all over came to listen to him and they thought to themselves, “Rama has gained so much knowledge at such a young age. How surprising! How great! What is the use of our living so long?”