Answer:
Indications are that cats don't purr only when they are content and happy. They also purr during tense moments, or even through trauma. When suddenly and violently injured, even near death, a cat will often purr. It has been suggested that it's a self-calming action, so they may even purr when they're scared or hurt. Scientific research suggests that purring releases endorphins, which are natural analgesics that reduce pain during the healing process.
However, cats also purr during peaceful or happy moments. Kittens instinctively purr when they are nursing; some cats purr when they anticipate their next meal; and it's well-known how a cat will purr when seated contentedly in its owner's lap. It is believed that, being blind and deaf at birth, the original function of purring was to enable a kitten to communicate with his mother. It communicates via this deep rumbling, and it can feel its mother communicating back via the same method.