The moral of "Jack and the Beanstalk" has to do with taking advantage of the opportunities that life provides. At the beginning, Jack is mired in poverty, selling his family's cow, which was a true act of desperation given that it was one of the family's last sources of sustenance. By the end, he has untold wealth, with the golden hen, and he is the village hero.
Jack's mother responds with anger when he returns home with a handful of beans because she is expecting something that she views as useful — such as money. Instead, he comes home with something that is virtually worthless in her eyes, and so she throws them out the window.
However, the beanstalk that grows up into the sky is Jack's opportunity to escape. He wants to redeem himself in his mother's eyes (and his own), and so when he sees the stalk, he climbs it, even though he has no idea where it leads. It is the acceptance of this risk that ends up transforming his life.
While not every risk leads to the discovery of a golden hen that provides a neverending supply of golden eggs, the reader walks away from this story with the knowledge that even the scariest risk brings the possibility of reward.