The Rambam explains that the purpose of Torah and its commandments is to perfect the soul — both the moral and intellectual faculties — and that study of Torah at its deepest level achieves this perfection.
פרק חמישי - בהשתמש האדם בכוחות הנפש לצד תכלית אחת צריך לאדם שישעבד כוחות נפשו כולם לפי הדעת, כפי מה שהקדמנו בפרק שלפני זה. וישים לנגד עיניו תמיד תכלית אחת, והיא: השגת השם יתברך, כפי יכולת האדם לדעת אותה. וישים פעולותיו כולן: תנועותיו ומנוחותיו וכל דבריו מביאים לזו התכלית, עד שלא יהיה בפעולותיו דבר מפועל ההבל, ר"ל: פועל שלא יביא אל זאת התכלית. מה שהוא מהן דרך לתכלית ההיא - אין בו דין ודברים. ומה שאין בו תועלת בתכלית ההיא: כשאלת החשבון, וספר החרוטים והתחבולות, ולהרבות משאלות אל-הנדסה, ומשיכת המשקלים, והרבה כיוצא באלו - תהיה הכונה בהם לחדד השכל ולהרגיל כוח השכלי בדרכי המופת, עד שיגיע לו לאדם קנין ידיעת ההקש המופתי מזולתו, ויהיה לו זה הדרך שיגיע בו לידיעת אמיתת מציאות השם יתברך.
CHAPTER V CONCERNING THE APPLICATION OF MAN'S PSYCHIC FACULTIES TOWARDS THE ATTAINMENT OF A SINGLE GOAL As we have explained in the preceding chapter, it is the duty of man to subordinate all the faculties of his soul to his reason. He must keep his mind's eye fixed constantly upon one goal, namely, the attainment of the knowledge of God (may He be blessed!), as far as it is possible for mortal man to know Him. Consequently, one must so adjust all his actions, his whole conduct, and even his very words, that they lead to this goal, in order that none of his deeds be aimless, and thus retard the attainment of that end. Concerning those which lead directly to this goal, there is naturally no question; but such subjects as mathematics, the study of conic sections, mechanics, the various problems of geometry, hydraulics, and many others of a similar nature, which do not tend directly towards that goal, should be studied for the purpose of sharpening the mind, and training the mental faculties by scientific investigations, so that man may acquire intellectual ability to distinguish demonstrative proofs from others, whereby he will be enabled to comprehend the essence of God.