annoyed or frustrated by something, or to have hidden listening devices placed to spy on someone.
From 'bug' meaning insect, which evolved to mean a defect or annoyance (1890s). The sense of 'to bother' came from the idea of insects being irritating. The surveillance meaning emerged in the 1900s from the small size of microphones.
The shift from 'annoying insect' to 'annoying problem' to 'secret microphone' shows how language adapts—people noticed that bugs are tiny and hard to find, just like early spy devices, so the word stuck!
Complete word intelligence in one call. Free tier — 50 lookups/day.