According to Lennon, the song's origins can be found when the English journalist Kenneth Allsop made a remark that Lennon should write songs about his childhood. Afterwards, Lennon wrote a song in the form of a long poem reminiscing on his childhood years. The original version of the lyrics was based on a bus route he used to take in Liverpool, naming various sites seen along the way, including Penny Lane and Strawberry Field. Those original lyrics are on display at The British Museum.
Original lyrics to John Lennon's "In My Life"
However, Lennon found it to be "ridiculous", calling it "the most boring sort of 'What I Did On My Holidays Bus Trip' song"; he reworked the words, replacing the specific memories with a generalized meditation on his past. "Very few lines" of the original version remained in the finished song. According to Lennon's friend and biographer Peter Shotton, the lines "Some [friends] are dead and some are living/In my life I've loved them all" referred to Stuart Sutcliffe (who died in 1962) and to Shotton.
Regarding authorship of the melody, Lennon's and McCartney's recollections differ. Referring to McCartney, Lennon said "his contribution melodically was the harmony and the middle-eight itself." McCartney claimed he set Lennon's lyrics to music from beginning to end, taking inspiration for the melody from songs by Smokey Robinson & the Miracles. "I liked 'In My Life'. Those were words that John wrote, and I wrote the tune to it. That was a great one."
The song was recorded on 18 October 1965, and was complete except for the instrumental bridge. At that time, Lennon had not decided what instrument to use, but he subsequently asked George Martin to play a piano solo, suggesting "something Baroque-sounding". Martin wrote a Bach-influenced piece that he found he could not play at the song's tempo. On 22 October, the solo was recorded with the tape running at half speed, so when played back at normal pace the piano was twice as fast and an octave higher, solving the performance challenge and also giving the solo a unique timbre, reminiscent of a harpsichord.
^The section to which Lennon referred is unclear, as the song does not contain a recognisable middle-eight aside from a brief instrumental break (the melody for which is attributed to producer George Martin).