When you hear someone refer to "purity" in the context of virtue, what usually comes to mind?
I'll give you three guesses, and the first two don't count.
We tend to think of purity strictly in the sense of suppressing our sexual desires. Or at least, suppressing sexual desire for people we're not married to.
My opinion is that this is exactly what Satan wants us to think purity is. It focuses on how God allegedly wants to deny us pleasure, or worse, our natural bodily urges. Big bad God, denying us something we can't help but feel as humans. This is not the way it is, though.
What is true purity? Purity, or better yet purity of heart, is making choices without selfish interest. In other words, making decisions with the right motives or intentions. Choosing to love and not to use. (John Paul II, in his book Love and Responsibility written before he was Pope, argues that the opposite of to love is not to hate, but to use [for selfish gain].) Purity means having an undivided heart, free of mixed motives. It's the opposite of corruption.
Certainly, this has sexual import. If you look at a person and think of how that person can satisfy your desire for pleasure, that is an impure look. If you look at a person and say, holy cow, God is good! when you see her gifts, that is not an impure look. ;-) If you look at someone as an object of use, as a means for attaining a selfish goal, that is what makes a look (or action) impure. It's not the sexual component that makes it impure, but what you intend to do — what your motives are — that makes it impure.
How can we battle impurity? At its root, as I said, impurity involves looking at someone as an object of use, and not as a person to love (love in the sense of desiring their highest good, apart from our own interests). A very effective way to do this is to find ways to treat the person as a person. A way you can always do this is to pray for the person — that is a form of pure and disinterested love. This might be how such customs arose, but things such as opening the door for someone or doing them some polite kindness is another way. Treating a person with respect is a generic way of treating them as a person. Talking to the person, trying to get to know them and their interests is another way. Yes, even thanking God for the person's beauty or obvious endowments is a way of treating them as a person! (Also they are a movement to prayer, that they would use them rightly in the service of good, and not for evil.)
So the point of maintaining custody of the eyes and avoiding sexual thoughts is not to deny our sexuality, but to ensure we treat everyone, especially those we find sexually attractive, as a person, with their best interests at heart, not motivated by our own pleasure or selfish desires. Sexual love is oriented to total and mutual self-giving. Any sexual thought that is not in conformance with that is an impure thought, as are a host of thoughts that have nothing to do with sexuality.