Why your cat purrs has been a very complicated questions scientists have been working on, some of the explanations we have so far are the following:
Your cat purring is a sign that they are very happy and excited, sometimes curled up in your lap getting pets or rolling around in the sun. Your cats purring is a indicator that they are happy and enjoying themselves in that moment.
When acts get stressed or nervous they may purr to help themselves calm down and relax. Sometimes when the vacuum or fireworks outside make them anxious you may find them under a bed purring to themselves.
Scientists have also found that cats purr at a specific frequency of 24 - 140 vibrations per minute to relieve pain, heal wounds, and promote bone growth. So cats may be purring for their own health.