The Rabbis taught: The Torah says, Visamtem "And you shall place these words of Mine on your hearts and on your souls..." (Devarim 11:18). You can also read that as "sam tom," a perfect medicine. The Torah is the perfect medicine.
The Rabbis gave a parable, comparing it to a man who wounded his son, so he put medicine and a bandage on the wound. He told his son, "As long as you keep the bandage with the medicine on your wound, you can eat with pleasure, drink with pleasure, you can wash with hot water or cold water, and you don't have to worry about it. If you take off the medicine, it will get gangrenous."
Likewise, Hashem has told Yisrael, "My children, I have created the Evil Inclination, and I have created the Torah as an antidote against it. I wrote in My Torah: "If you do good, you will be more powerful. If you do not do good, sin awaits crouching at the door; it desires to control you, but you can overpower it" (Bereishit 4:7).
As long as you are engrossed in the Torah, you will not be controlled by the Evil Inclination. This is why the Torah says: "If you do good, you will be more powerful." But when you are not engrossed in the Torah, you will be under the control of the Evil Inclination, as the verse continues, "If you do not do good, sin awaits crouching at the door."
"Not only that," Hashem said, "but the Evil Inclination will spend all its time and energies trying to make you sin, which is why the verse says "it desires to control you."
"If you want to, you can overpower the Evil Inclination, as it says, "...it desires to control you, but you can overpower it."
-Kiddushin 30b