Whatever the case, "foo" became associated with "bar" via WWII slang "FUBAR"; WWII also gave us "foo fighters" in the UFO sense. War is like the internet in that it brings together people of different backgrounds who otherwise might never interact, so it's not surprising that with things like foo, FUBAR, and Kilroy, WWII had something resembling a predecessor of modern meme culture. It entered hacker culture via the MIT TMRC culture in the 1950s. Their railroad layout had a "foo counter" which was a digital clock which would display the word instead of the time when certain scram switches were pressed. When MIT people began cultivating an interest in programming computers for its own sake, they brought "foo" with them and it spread into the greater hacker meme diaspora.
There's nothing quite as hacker-y as the word "foo", and the strong association with hacker culture goes back as long as hacker culture was a thing, and even before. It still reminds us to not take things so seriously, mess around, and have a little fun.