A fly is a specific type of insect with wings. They are known as pests, and can sometimes carry disease. In ancient Earth, the resin of coniferous trees would entrap these insects. The remains of these insects was fossilized in the resin (amber).
When Sito Jaxa suggested that it would be good to be a spider under the table of the observation lounge, Sam Lavelle compared this to be a fly on the wall. They were talking about the meeting of the senior staff in the observation lounge and were curious what they were talking about. (TNG: "Lower Decks")
Roy was a holographic fly created by Doctor Lewis Zimmerman in the 2370s for Starfleet Intelligence as a new form of micro-surveillance on the "Trojan Horse Project". When his mission was complete, Dr. Zimmerman kept him around on Jupiter Station as a pet. He nonetheless often landed on The Doctor's food. (VOY: "Life Line")