The Midrash tells that each day, King David would have plans for the day, intending to go to various places and to see different people, but his legs always brought him to the Bet Midrash to learn Torah.
The Or Ha'haim (Rav Haim Ben-Attar, 1696-1743) understood the Midrash's comment literally, that King David's legs had "a mind of their own," so-to-speak, and would bring David to the study hall despite his plans to go elsewhere. David had such a strong, deep-seated desire to learn Torah that his legs automatically took him to the Bet Midrash, even when he did not plan to go there. The Or Ha'haim explains on this basis the Torah's promise of great reward "Im Be'hukotai Telechu" – "If you walk according to My statutes" (Vayikra 26:3). This means that we are worthy of great reward if we feel such love and passion for Torah that we walk "Be'hukotai" – toward the Torah's laws, to learn, even when we do not intend to, because our legs automatically bring us to the study hall.
Hacham Baruch Ben-Haim, however, offered a different explanation of the Midrash's comment. He said that each morning, the Yeser Ha'ra (evil inclination) would try to convince David to stay in bed, and David fought the Yeser Ha'ra by saying that he needed to get up to tend to his personal affairs. The Yeser Ha'ra has no problem with us getting up for mundane purposes, and so it left David alone and discontinued its efforts to persuade David to remain in bed. Once David got out of bed without having to struggle against the Yeser Ha'ra, he then went to the Bet Midrash to learn Torah instead of tending to his personal affairs. This was David's strategy for defeating the Yeser Ha'ra in the morning and overcoming the difficult challenge of getting up early to serve Hashem.
This reading of the Midrash perhaps sheds light on a difficult verse in Shir Hashirim (4:16): "Uri Safon U'bo'i Teman" – "Arise in the north, and come to the south." The north is associated with material blessings, as the Shulhan (table) in the Mishkan – which symbolized Parnasa (livelihood) – was positioned to the north side. The south is associated with Torah wisdom, as the Menorah – the symbol of the "light" of Torah – was situated along the southern wall of the Mishkan. For this reason, the Gemara teaches that one who seeks wealth should turn somewhat to the north while praying, whereas one who seeks Torah wisdom should turn somewhat to the south. Accordingly, the verse in Shir Hashirim may be understood to mean that we should tell the Yeser Ha'ra in the morning that "Uri Safon" – we are waking up for the sake of pursuing wealth, to work and make a respectable livelihood, as the Yeser Ha'ra will then cease his efforts to convince us to stay in bed. But thereafter, "Bo'i Teman" – we should go "south," to the synagogue and study hall to pray and immerse ourselves in Torah study.

