The Yetzer Hara's biggest tool in getting people to sin, is depression. One way to always remain happy is to remember that everything we go through in life - including all of the "unfulfilled" desires that we think we need and all the suffering that we endure, it is all only for our good. We are designed and programmed by God to attain lasting pleasure. That's our function. God is not stingy. He wants us to have the premium -- the greatest possible pleasure, just like most parents want nothing less for their children. Anything less than the very best would smack of imperfection, in contradiction to God's perfect essence. We must believe that this is the best possible world, since it is a reflection of God's perfection. "Since God desired to bestow good, a partial good would not be sufficient. The good that He bestows would have to be the ultimate good that His handiwork could accept." (The Way of God, 1:2:1). Since God is perfect and has no needs, He cannot take; He only gives. Creation is not for His benefit. It is one continuous gift of pure altruism, an act of complete giving without getting anything in return. "God's purpose in creation was to bestow of His good to another." [Rabbi Moshe Chaim Luzzatto, The Way of God, 1:2:1].
One way to perfect this frame of mind of how G-d deals with us, is to look at how we deal with our own kids. We all know that kids hate school and would rather stay home. So why do we parents force them to go? Obviously we want the best for them, but they are too young to understand that we are leading them down a path of opportunity and lifelong fulfillment for their own good. However, if the child would truly trust that the parent wanted only the best for him, the child would be able to keep a happy frame of mind while going to school. He would be just as happy as an adult who was accepted to a big-name university to study for a prestigious degree for the job of his dreams.
Obviously, this frame of mind requires a lot of faith, but if we work on it enough we can be given the gift by God to start to truly feel it. And with this frame of mind, a man can achieve the ultimate happiness and be saved from sin. Every test we go through is another step towards graduation in this incredible opportunity of a school called "Life". Keep happy, you are in the best school possible and your teacher is none-other than G-d himself!