Many of these, such as endorphins, are directly associated with emotions. Each of your immune cells have receptors for all of these chemical messengers as does your gut and virtually all of your internal organs. This ancient part of your brain is the seat of your deep emotions and instinctive drives. Evolution works by culling the weak and preserving the strong. Mating battles in some species allow only the strongest to reproduce.
Predators cull the weak in others.
Perhaps the weakening of the human immune system by feelings of helplessness is nature's way of culling the outcasts and the unsuccessful to improve the breed. One massive study in Finland examined the health records of 96,000 widowed people and found that their probability of dying was actually doubled in the week after losing their mate. Feelings of pleasure and well-being have the opposite effect. They indicate that you are thriving and your immune system responds by working at peak efficiency so that you can survive and reproduce. The feeling of exultation that follows successfully dealing with a challenge actually energizes your immune system.