"There are no atheists in foxholes"
This familiar expression informs us that when in situations of peril or imminent doom, human nature forces us to turn to god(s) for help, due to the realization that we are at times unable to help ourselves. I propose that life itself is such a situation - we are all in constant, mortal danger. At any moment, any one of us could drop down dead where we stand, either by natural causes (heart attack, stroke, etc), or unnatural causes (hit by crashing plane, shot by crazed gunman, etc). If one accepts the existence of god(s), then one can console one's self with the knowledge that life will continue on after the death of one's body. However, given the complete absence of empirical evidence to support the existence of an afterlife, can we scientifically claim that such consolation is valid, or must we inexorably arrive at the conclusion that it is, in fact, delusional?
Delusions of immortality and divine protection are useful for getting through short-term, disastrous scenarios (by giving one the confidence that one needs to overcome the immediate obstacles in one's path), but they can easily become a crutch on which one finds one's self totally dependent if used in a general sense. Such delusions can also easily result in overconfidence, leading to dangerous, reckless, or even self-destructive behaviour.
Having established that such self-delusions can be dangerous, it is tempting to suggest that the delusion should be discouraged or stripped away, but what effect would that have on those who have come to rely on the delusion? The sudden destruction of the foundation of one's confidence - real or imagined - could have devastating effects on one's ability to deal with hardship. We now see that the delusion may in fact be necessary; the lesser of two evils.
So what has this all got to do with happiness? I submit that happiness is a defence mechanism, one which allows us to selectively ignore certain negative aspects of one's life while simultaneously mentally augmenting the positive aspects. This warped and biased perspective then allows us to believe that all is well, and the resulting mental state (i.e. happiness) is pleasurable enough to allow us to endure what might otherwise be unendurable.
For example, meet Bob - Bob is a middle-aged man, married, two children, owns his own home, and is reasonably successful in his chosen field. Bob is happy. Bob's happiness is derived from his reasonably successful marriage and his reasonably successful career. Bob chooses not to think about the possibility that his young son could be hit by a car every time he walks home from school, or that his high school-aged young daughter could be raped each time she goes to a party. Bob is aware of cancer, heart disease, diabetes, alzheimer's, and a whole host of other medical ailments but chooses not to dwell on the very real possibility that he or his wife could be diagnosed with one or more such ailments at virtually any time. Bob also knows of such things as housefires, home invasions, muggings, random shootings, floods, earthquakes, and meteors, but doesn't concern himself very much with any of them. Finally, Bob is aware that he is a living creature, and that like all living creatures, he will inevitably die, as will his wife and children. At some level, Bob is aware that everything he owns is temporary, and that everyone he knows will die, and that nothing he can say or do will ever change that.
And yet, Bob is happy.
So where does Bob's happiness come from? Objectively, we see that Bob's level of suffering is at a fairly low point, but certainly we realize that this is a temporary condition. Bob's life has no objective meaning, and even if it did, that meaning would certainly cease when he dies. Bob's selective perception allows him to focus on the most pleasant and positive aspects of his life, while ignoring certain other truths. This bias stems from a disorder; an impairment of judgement which, although generally beneficial, is nonetheless a cognitive malfunction. Bob is capable of seeing things the way they are, but instead chooses to see things the way he wishes they were. His daughter is a sweet little princess, his son is a star athlete, his wife is loving and devoted. All of them will live happily ever after.
Bob's delusion may very well leave him ill-prepared to deal with unexpected calamity.
To summarize - that which we call "happiness" is really your brain's way of keeping you from going completely insane from the sheer horror and despair of the cruel and uncaring world in which we live.