The Torah actually has two purposes: our physical well-being and our spiritual well-being. (III, 27)
The Torah regulates our spiritual well-being through its philosophies. These philosophies must be communicated to the people according to their ability to understand them. Some of these are beyond the average person’s capacity. For this reason, some things are stated straight out while others are communicated through allegories.
The Torah regulates our physical well-being through managing our interpersonal relationships. People may not do absolutely anything they desire; rather, everyone must contribute toward the common good. This helps to remove violence and oppression from our society. Also, the Torah teaches us good morals, which helps to build society.
Spiritual improvement is the ultimate goal of the Torah but this can only be accomplished through perfection of the physical side. Therefore, the physical aspect is addressed in great detail. Perfection of this kind can only be achieved when a person’s temporal needs such as food and shelter are met. A person cannot accomplish everything necessary in this area on his own; it requires a society working together.
After satisfying that which is necessary for the body, a person can work on perfecting his soul. This entails knowing all the things that a spiritually-perfected person must know. For this goal to be met, no action or deeds are required, just thought and investigation.
Satisfying the physical needs first is necessary because if a person is suffering from hunger, cold, or other discomforts, he cannot fully grasp ideas presented to him by others, let alone invest himself sufficiently to do his own philosophical speculation and reasoning. When his physical needs are met, then he can focus on his spiritual perfection, which is the higher purpose of the Torah.
The Torah itself tells us of this two-fold purpose. Deuteronomy 6:24 says, “Hashem commanded us to do all these statutes, to fear Hashem our God, for our good always, that He might preserve us alive, as it is this day.” The second goal – “for our good always” – is mentioned first because it is the ultimate purpose of the Torah: to help us enter the World that is eternally good. The initial goal, which is a means to this end, is “that He might preserve us alive, as it is this day,” in the context of a well-functioning society.