While this question borders on being outside the scope of Stack Overflow, I highly recommend the Wikipedia article on the matter:
The History of Foobar
To give a quick preview:
The word foo originated as a nonsense word from the 1930s, the
military term FUBAR emerged in the 1940s… The
term foo fighter was used by Allied aircraft pilots in World War II to
describe various UFOs or mysterious aerial phenomena. The first known
use of the terms in print in a programming context appears in a 1965
edition of MIT’s Tech Engineering News.