There seem to be a number of reasons that cats purr. It may help to think of a cat’s purr like a dog’s bark, or a person’s laugh. Dogs may bark as a warning because they hear something; because they’re hungry or need to go outside; or simply because they’re excited. A person may laugh from mirth, or when nervous, startled or scared, or simply to be polite.
Purring doesn’t necessarily indicate pleasure, though this is a common perception and may possibly be the most likely (and enjoyable) reason we hear cats purr. A cat may purr to signal that it is friendly to a human or another cat. Purring may be done as a way to get a human’s attention because the cat wants something, like food or a lap and petting.
Purring can change dramatically based on the situation. When their cat is hungry, owners have reported a sense of urgency to feed it when hearing its purr. In fact, in a study done by Dr. Karen Macomb and her team at the University of Sussex, it was determined that even people who had never owned a cat could hear something different in certain purrs, like when the cat wanted food:
When we conducted playbacks of purrs from 10 cats recorded in both solicitation and non-solicitation contexts to 50 human participants at equal amplitude, they consistently judged the solicitation purrs to be more urgent and less pleasant than the non-solicitation purrs and when given the choice between pairs of non-solicitation and solicitation purrs from the same cats they identified the solicitation purr as the more urgent and less pleasant of the two.
Interestingly, the sound frequency used in the solicitation purr is similar to the cry of a human infant, which may help explain why it is so irresistible.
Cats also sometimes purr when experiencing negative stimuli, such as when they’re scared or injured. It has been theorized that purring may act as a means of self-soothing, possibly releasing hormones which act as painkillers.
Perhaps the most interesting use of purring is the possibility that it can stimulate bone growth. Cats purr at frequency of around 25Hz; a study published in 2001 showed that "high frequency (10–100 Hz) and low magnitude stimuli were capable of augmenting bone mass and morphology, thereby benefiting both bone quantity and quality."
Cats typically lead very sedentary lives, which is not exactly conducive to a healthy cat with solid bones. They are predators, and in their natural environment, lots of time spent lying around between hunts means lots of time to lose bone density; the vibration caused by purring may be the way nature came up with to combat this.
You might have noticed a lot of "may" and "possibly" related to why cats purr, and there is a lot we still don't know about feline behavior. Unlike dogs, for example, who may be eager to please and willing participants in behavior research, cats tend to be more aloof and less eager to cooperate. Fortunately, understanding– or lack thereof– need not interfere with enjoyment and companionship shared with our furry, purring friends.