The original title of "War Pigs" was "Walpurgis", dealing with the witches' sabbath. "Walpurgis is sort of like Christmas for Satanists. And to me, war was the big Satan", said bassist and lyricist Geezer Butler. "It wasn’t about politics or government or anything. It was Evil itself. So I was saying 'generals gathered in the masses / just like witches at black masses' to make an analogy. But when we brought it to the record company, they thought 'Walpurgis' sounded too Satanic. And that's when we turned it into 'War Pigs'. But we didn't change the lyrics, because they were already finished."
During this time period, mandatory army service had recently ended in England but with the Vietnam War raging, many young men feared they'd be conscripted to fight in it. "That's what started this whole rebellion thing about not going to war for anybody", said Butler. "I was dreading being called up", the lyricist recalled.
Prior to its official release, the band often altered the lyrics significantly when performing it live. An example of this can be found on Ozzy Osbourne's compilation The Ozzman Cometh, which features an early version recorded by Black Sabbath for BBC Radio 1 on 26 April 1970. While Butler has said that "War Pigs" is "totally against the Vietnam War, about how these rich politicians and rich people start all the wars for their benefit and get all the poor people to die for them", vocalist Osbourne has stated that the group "knew nothing about Vietnam. It's just an anti-war song." The song's instrumental outro is entitled "Luke's Wall" on US releases of the album.
Drummer Bill Ward's first memory of performing the song was at The Beat Club in Switzerland in 1968. The band was required to play multiple sets every night and had little material in their repertoire at that point, so they would perform lengthy jam sessions to fill in the sets. Iommi has said that "War Pigs" originated from one of those jam sessions.
The addition of the air-raid siren and the speeding up of the song's end were done by producer Rodger Bain and engineer Tom Allom. The band had no input in these decisions, though they were pleased with the results.