Chazal say that if a person sanctifies himself on this earth, they also sanctify him on high. If he sanctifies himself a little they sanctify him a lot, and if he sanctifies himself in this world they sanctify him for the next world.
Behold! The sanctity of a man is dependent on guarding himself from all sin, in thought, speech and action. It is especially true that whenever one finds safeguards against immorality, one finds sanctity. Safeguarding against morality includes closing one’s eyes from seeing evil and distancing one’s hearts from foreign thoughts and evil feelings, and since he has sanctified his eyes and heart, he will automatically merit to reach levels of sanctity and all of his body will be sanctified. And this is the explanation of the verse “And you will not stray after your hearts and after your eyes… And you will be holy to your G-d!”.