The occasion that led Milton to write this was that he was graduating from university and he didn't know what to do with his life. There were pressures to both become an Anglican priest and to go to a school of fine arts. In the end he chose the second which turned out to be the best move he made in his life since he is after all one of the greatest poets in the history of the world.