People who are happy because of a strong sense of purpose and meaning, known as eudaimonic well-being, showed favourable gene-expression profiles in immune cells and had low levels of inflammatory gene expression and antiviral and antibody genes.
Participants with a more hedonic well-being, from consummatory self-gratification, showed the opposite reaction with inflammation and antivirals, the researchers stated.
The response likely developed to respond to microbial threats that came from changing conditions, lead researcher Steven Cole said.
"What this study tells us is that doing good and feeling good have very different effects on the human genome, even though they generate similar levels of positive emotion," Cole said.
"Apparently, the human genome is much more sensitive to different ways of achieving happiness than are conscious minds."
The study was published online in the journal Proceedings of the National Academy of Sciences.