mid-14c., "shopkeeper," especially "pharmacist; one who stores, compounds, and sells medicaments," from Old French apotecaire (13c., Modern French apothicaire), from Late Latin apothecarius "storekeeper," from Latin apotheca "storehouse," from Greek apothēkē "barn, storehouse," literally "a place where things are put away," from apo "away" (see apo-) + thēkē "receptacle," from suffixed form of PIE root *dhe- "to set, put."
The same Latin word produced French boutique, Spanish bodega, German Apotheke. Cognate compounds produced Sanskrit apadha- "concealment," Old Persian apadana- "palace."
Drugs and herbs being among the chief items of non-perishable goods, the meaning narrowed 17c. to "druggist" (the Apothecaries' Company of London separated from the Grocers' in 1617). Apothecaries were notorious for "the assumed gravity and affectation of knowledge generally put on by the gentlemen of this profession, who are commonly as superficial in their learning as they are pedantic in their language" [Francis Grose, "A Classical Dictionary of the Vulgar Tongue," 1796]. Hence, Apothecary's Latin, barbarously mangled, also known as Dog Latin.