How Seven Nation Army went from a saved Bond riff to football's favourite chant
Jack White wrote the Seven Nation Army riff in Melbourne in 2002 and held it back for a possible James Bond theme before it opened The White Stripes' Elephant in 2003. Club Brugge fans reportedly first chanted it in Milan in October 2003, Italy's fans carried it through the 2006 World Cup, and White wrote a real Bond theme in 2008.
By Riffiter

The riff that football crowds sing as "oh, oh-oh oh oh, oh, oh" was never written for a stadium. Jack White came up with it in Melbourne in 2002 and held it back in case he was ever asked to write a James Bond theme. When that looked unlikely, it became the opening track of The White Stripes' fourth album, Elephant.
A riff at the Corner Hotel
The White Stripes were on the Australian leg of their tour when White worked out the riff at the Corner Hotel in Melbourne, according to both Wikipedia and Radio X. He played it for Ben Swank of Third Man Records, who was not impressed. Wikipedia quotes White saying Swank felt he could "do better"; Radio X says Swank thought it was just OK.
White kept it anyway, saving it for a Bond theme that might never be offered. The sound itself is a guitar run through a pitch pedal an octave down, which is why so many people hear it as a bass line.

Elephant, 2003
White recorded the song at Toe Rag Studios in London as what he called "a little experiment": a song with no sung chorus, where the riff does that job. Seven Nation Army opened Elephant in 2003. In 2010 White recalled that the band's labels in Britain and America did not want it as a single at first, as Radio X reported.
How it reached the stands
The chant is usually traced to October 2003, when Club Brugge played AC Milan in a Champions League match in Milan. Brugge fans reportedly began singing the riff there and kept going after Andrés Mendoza scored the only goal; Brugge won 1-0. Wikipedia and Radio X both give this origin, and Radio X is careful to call it what "various sources" say, so treat the exact moment as likely rather than certain.
Italy is where it grew. Italian fans called it the "po po po" song and sang it through the 2006 World Cup. After Italy won the final, the riff was sung in the streets of Rome. White said he was honoured that Italians had "adopted this song as their own".

Since then it has turned up at the European Championships, in American football, basketball and hockey arenas, and at boxing walkouts. Speaking on CONAN in 2014, White said that as a songwriter it was the greatest thing that could happen to a song, because "it becomes folk music" once people take it over.
The Bond theme, after all
The call White had given up on came in 2008. He wrote and performed Another Way to Die with Alicia Keys as the theme for the Bond film Quantum of Solace. The riff he had saved for that job was, by then, already being sung in stadiums.