this article in the New York Times. I have a few theories of my own.
1. It's usually considered inappropriate to say things aren't great. If a Costa Rican tells you that things are "más o menos"(more or less) it's a good idea to ask what's wrong. He or a near relative might be gravely ill. Otherwise, the most common response to "¿Como está?" is "¡Muy bien por dicha!" (very well, luckily) or "¡Pura vida!" (pure life, a general purpose comment that means almost anything positive from life is great to don't worry about things.)
2. Ticos are very non-confrontational. They rarely complain about problems like noisy neighbors or slow service. This keeps life smooth and easy, if a bit noisier and slower.
3. When you are surrounded by smiling people who never complain and are always telling you how great things are, it just makes you feel better. The opposite of a vicious cycle. Scientific proof is found in this article. The authors analyzed long-term data from the Framington Heart Study and concluded:
People’s happiness depends on the happiness of others with whom they are connected. This provides further justification for seeing happiness, like health, as a collective phenomenon.
4. Most people are in the middle, economically. There's not a huge gap between the very rich and other people. True, there are rich and poor, but compared to many countries the divide between the extremes is less.
If you want to feel happier and can't come live in Costa Rica, you might want to check out the Happiness Project here. Pura vida.