"thing that provokes one most," by 1917, from pet (n.1) in the adjectival sense "especially cherished thing" (1826), here in jocular or ironic use with peeve (n.) and perhaps a suggestion of pet (n.2).
Entries linking to pet peeve
pet n.1
"domesticated or tamed animal kept as a favorite," 1530s, originally in Scottish and northern England dialect (and exclusively so until mid-18c.), a word of unknown origin. Sense of "indulged or favorite 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.
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"]
It is an amiable part of human nature, that we should love our animals; it is even better to love them to the point of folly, than not to love them at all. [Stevie Smith, "Cats in Colour," 1959]
In early use typically a lamb brought up by hand (compare cade); but the earliest surviving reference lists "Parroquets, monkeys, peacocks, swans, &c., &c." As a term of endearment by 1849. Teacher's pet as a derogatory term for a teacher's favorite pupil is attested by 1854, American English. Pet-shop "shop selling animals to be kept as pets" is from 1928.
peeve v.
"irritate, exasperate," 1907 (implied in peeved), back-formation from peevish. Also "to grumble, complain" (1912). As a noun, attested by 1910. Related: Peeved; peeving; peeves.
pet n.2
"fit of peevishness, offense or ill-humor at feeling slighted," 1580s, in phrase take the pet "take offense." Perhaps from pet (n.1) on a similar notion to that in American English that gets my goat (for which see goat), but the underlying notion is obscure, and the form of the original expression makes this doubtful. Perhaps from the notion of "characteristic of an indulged or spoiled child," but OED notes that this word seems to have been originally a southern English term, while pet (n.1) was northern and Scottish. Perhaps influenced by unrelated petulant.