"A fly in the ointment" is a very old idiom, probably
derived (as are so many things in western culture) from the Bible:
Dead flies cause the ointment of the apothecary to send forth a
stinking savour: so doth a little folly him that is in
reputation for wisdom and honour.
It refers to someone or something that ruins an otherwise perfectly
good state of affairs. It's generally a small thing, an annoyance,
rather than something huge and catastrophic.