A pet's Safety decreases by 1 per hour. When it gets to 0 or below, the pet cowers in a corner, and the increase of Love, Esteem, and experience points becomes impossible.
A sleeping pet does not lose any Safety.
As a pet feels less safe, it is more likely to spend its hourly action being comforted by safety items in the house (pillows and plushies, for example).
A few foods provide Safety when fed to a pet, and many half-hourly actions - including petting - provide Safety, when taken.
The Moat add-on provides a passive safety bonus to pets in your house from hour to hour, slowing their decline. Having a house full of friendly pets can also maintain a feeling of safety in this way.