The phrase means putting massive effort into achieving something minor or unimportant.
It is derived from Alexander's Pope Epistle to Dr Arbuthnot of January 1735.
"
Let Sporus tremble –"What? that thing of silk,
Sporus, that mere white curd of ass's milk?
Satire or sense, alas! can Sporus feel?
Who breaks a butterfly upon a wheel?"
Yet let me flap this bug with gilded wings,
This painted child of dirt that stinks and stings;
Whose buzz the witty and the fair annoys,
Yet wit ne'er tastes, and beauty ne'er enjoys, "