This story happened in 1947, at Harvard University, when a computer of those facilities (Mark II) began to have a malfunction. Some engineers found a moth stuck in the machine, removed it and the fault was removed.
Since then it began to say that the computer has a ‘bug’ (insect) when it began to fail.
For a while it was thought that Grace Hopper had been the one who discovered the insect on the computer, but she herself recognized that it was not so.
Grace Hopper was a computer scientist and US military with the rank of Rear Admiral, sent to Harvard to work on the construction of the Mark I, the first electromechanical computer that worked with relays, switches and perforated paper. Which is about 15.5 meters long x 2.40 meters high x 60 cm wide, so the computer had about 760,000 wheels, plus 800 kilometers of cable and weighed 5 tons.