Lions can't purr. If you can roar, you can't purr. But if you are another wild cat, like a civet, mountain lion or bobcat, purring is your unique gift. The laryngeal muscles oscillate at 25–150 Hz causing a sudden separation of vocal cords during both inhalation and exhalation. Our companion cats do seem to purr more often when they are contented with their situation but that isn't the only time they purr. The purr is so low-pitched that we almost feel it as much as we hear it.
Cats also purr when they are frightened or stressed. Often, cats will purr in the context of the veterinary visit, which is always a bit stressful. Theories abound, but like the smile in humans, perhaps it is an appeasing gesture in that context. It might be similar to the reasons people smile, contentment surely, but also when we are nervous or want something.