I can't blame medieval scholars for believing that flies spontaneously generated from things like raw meat (instead of reproducing). I would guess that fruit flies played a major role in supporting this theory.
But how are they born? I'll have no fruit flies in the house, and then I'll forget a potato, it rots, and then I'll be infested with fruit flies. Were they already on the potato before it rotted, or did one just happen in, found some food, and figured it would stay and start a family here?
This is what I always wondered about maggots, like when a person in any kind of sealed room, anywhere, dies and starts to decompose. I've been lead to believe maggots inevitably appear and start the process but where did the larvae come from?! Food?
IIRC, I read in _The Violinist's Thumb_ that fruit flies are a more recent import along with tropical fruits (I think bananas?), so the spontaneous generation theory would predate their presence in the West.
https://en.wikipedia.org/wiki/Spontaneous_generation