FOO comes from a very old (1930s) comic strip called "Smokey Stover". The author got it from the Chinese word 'fu', meaning prosperity. FOO reappeared in a few unknown comics books and magazines in the 1950s.
A few other spottings occur in a military context...
"FOO was here", used by the British.
"FOO Fighters", used by the USMarines.
As far as the modern definition for "Foo" in the context of programming, I see it a lot using the Java language. It is used to refer to something that can be anything because it doesn't matter what the thing really is. It's like saying "whatchamacallit", or as they say in Hawaii, "da kine".
Synonymns of "Foo" include:
thing
thang
x
something-something
do-hicky
damnit
For more information search,
"what is foo" on a search engine, foo!