Calling companion animals ‘pets’ is not popular among animal advocates as it is slightly demeaning (‘he’s teacher’s pet’). It’s a throwback term; ‘companion animal’ is better. If the animal is a cat, ‘cat companion’ is more modern.
Having got that out of the way, we don’t know for sure why companion animals are called pets! We would only know for sure if we know the origin of the word and we don’t.
‘To pet’ which means to stroke and touch nicely must be the verb version of the noun ‘a pet’.
‘Pet’ appears to come from the Scotland or the north of England in 1500s. It might come from the word ‘petty’ meaning small or little as in “it’s a petty matter”. Petty is also used in phrases such as, “you’re petty-minded” or “petty officer’.
The word ‘petty’ comes from Middle French ‘petit’ since the 14th century. Petit means small in French.
So the best answer might be:
Petit (small) > petty (small) > pet (small companion animal).
Although ‘pet’ is also used to describe large animals as in “he’s my pet crocodile!” The application of the word to large animals is just an extension of the use of the word to mean friendly.
Please search using the search box at the top of the site. You are bound to find what you are looking for.