With touring no longer a concern, all four Beatles found themselves with a great deal of time on their hands. So, Paul undertook the project of writing music for the film The Family Way; George vacationed to India to take sitar lessons from Ravi Shankar; Ringo stayed at home – something the Beatles rarely did due to their grueling schedule – so he could spend time with his wife and their 1-year-old son, Zak; and John flew to Spain to act a minor role in Richard Lester's film How I Won the War. "I said yes to Dick Lester that I would make this movie with him and I went to Almería Spain for six weeks just because I didn't know what to do. What do you do when you don't tour? There's no life" (Anthology, Episode 6).
The film is a black comedy about an inept and fictional regiment during World War II. It was intended as an anti-war protest - something that would dominate Lennon's own actions in the subsequent years - due to the escalating conflict in Vietnam. Lennon plays the role of Musketeer Gripeweed. The appearance of a Beatles has ensured its historical survival, but it seems otherwise forgettable. (It's available via instant streaming on Netflix as of February 2013.)
Having acted in both A Hard Day's Night and Help! (both of which were also directed by Richard Lester), Lennon knew roughly what to expect. However, acting as an individual in a film is very different from acting as a band in a film and Lennon, notoriously impatient, quickly found himself quite bored. So he kept a guitar nearby to help pass the time between takes. It was in Spain, during the filming, that he began work on the song that would eventually become "Strawberry Fields Forever", originally titled “It's Not Too Bad”.
Beatles. The Beatles Anthology. DVD. Apple Corps Limited, 2003.