Everything in the world has a means and a goal, and since the means merely bring a person to his goal, the means are always considered secondary to the goal. For example, if a person has a store, that is the means, and the goal is the income from the store. Surely the expenses on the store are less than the income he expects to gain, which is the goal. Similarly, if a king spends a fortune building a palace, he expects the palace to benefit him more than the money spent on it. When we see that Hashem created the whole world with all the myriad creations within it, and He revealed that every detail of creation has only one purpose that without it He would never have created it, we can understand how lofty this purpose is. Hashem revealed through His prophet Yirmiyahu that the whole world was created just for Torah, as it says, ‘If not for My covenant day and night I would not have created the laws of nature’.
This is a complete refutation of the claim some people make that they have to teach their children something with a goal to it, and the verse cries out that there is no other goal than Torah, and all other goals are only means to this end. The Torah is the ultimate good and the eternal existence a person can attain, and in its merit a person will sit in the presence of the King of Glory.