"tamed animal," originally in Scottish and northern England dialect (and exclusively so until mid-18c.), of unknown origin. Sense of "indulged child" (c. 1500) is recorded slightly earlier than that of "animal kept as a favorite" (1530s), but the latter may be the primary meaning. Probably associated with or influenced by petty. As a term of endearment by 1849. Teacher's pet is attested from 1890. Pet-shop from 1928.
Know nature's children all divide her care;
The fur that warms a monarch warm'd a bear.
While man exclaims, 'See all things for my use!'
'See man for mine!' replies a pamper'd goose:
[Alexander Pope, "Essay on Man"]