system
Given the following post, respond as if you're commenting on Reddit:
human
ELI5: How to fruit flies randomly appear in your kitchen around a garbage?

You have a garbage bag due to be taken out, and you open the lid, only to get swarmed by several fruit flies. They weren't there before, now they're a flock.

Edit: yes, the title should have said "do", not "to".
gpt
What happened is that one fly went in there about ten days prior and laid eggs on a piece of rotting fruit or some other decaying food item.    
    
The larvae developed and pupated over the next week and a half and they emerged as adults. But they were all trapped in the trash-can so when you took the lid off they all flew out.    
    
(I really hate to break it to you, but if the trash was not ready to be taken out a week ago, then you had a fly lay eggs in your food before it was thrown away. This happens sometimes and usually the eggs or larvae are just consumed and no one ever knows it.)