Paul McCartney wrote this on a sunny day at John Lennon's house. It was influenced by the Lovin' Spoonful, who had a happy hit with "Do You Believe In Magic?"
The actual Lovin' Spoonful hit which inspired this song was "Daydream
," a famously carefree, upbeat tune. McCartney confided in interviews that it was intended to evoke "the same traditional, almost trad-jazz feel" and that "Good Day Sunshine" was Paul's effort to write something in the same spirit.