Cats purr as a form of communication to signal either contentment or anxiety. Purring is a vital part of a cat's interaction with other felines and begins in the second day of a cat's life.
A cat's first use of purring occurs while nursing. Cats cannot meow while feeding, but they can purr. This tells the mother cat that her kitten is doing well and that there's no reason to be worried. The mother cat may purr back to her kitten as a way of signalling that the kitten is safe while feeding.
As cats get older, their purrs tell other felines as well as humans that they are in a peaceful mood. This is common during grooming and signals that the groomer should continue grooming the cat. It is also used as a greeting to let another cat know there is no threat of aggression.
While less common, cats occasionally purr when frightened or in pain. This is most often seen when a mother cat is in labor. It also happens when a cat is sick or injured. While the reasoning for this is not perfectly understood, according to PetPlace, it is believed that the cat is trying to reassure himself in a fashion similar to the way people might mumble encouraging words to themselves when frightened.