The other day I was talking to a friend about the history of the Jewish people, and he told me something very interesting: from the day people stopped going to consult the rabbi, they started going to the psychologist.
Everyone is at least somewhat familiar with the basic concept of a psychologist: trying to resolve internal, mental, or emotional conflicts based on different models of interpreting the human mind and heart. It's understandable that people consult a psychologist.
However, why did people go to the rabbi? A rabbi's basic function is to know the laws of the Torah in order to teach or rule on whether a particular object is appropriate, whether a behavior is correct, or to resolve conflicts of rights between people. Isn't the Torah a book of laws? What does the law have to do with mental and emotional matters?
Maimonides writes at the end of his compilation on the laws of Hanukkah that the reason God gave the Torah is to bring peace to the world. And not only to the world in the literal sense of the word (between people) but also to the small world of man; peace with others and peace with oneself.
This is why people consulted a rabbi. But even after all this, our question remains: What does the law have to do with mental and emotional matters? The answer is quite simple. One of the first things one learns when beginning to study Torah (and indeed, it is one of the greatest motivators for approaching the path of Torah and Mitzvot) is to shift one's focus.
From birth, we learn to focus on our own needs—food, clothing, shelter, work, all kinds of personal necessities. The Torah teaches us to focus on the needs of others. By thinking about and seeking what God wants from us (instead of thinking about what I want from God), we learn to consider and think about the needs of those around us.
This is the meaning of the idea that the Torah was given to bring peace to the world. The Torah teaches us to think about God. And with this, it focuses us on a mental and emotional state of thinking about others.