From the Wikipedia entry:
The Beatles recorded "We Can Work It Out" on 20 October 1965, four days after its accompanying single track, with an overdub session on 29 October. They spent nearly 11 hours on the song, by far the longest expenditure of studio time up to that point.
In a discussion about what song to release as a single, Lennon argued "vociferously" for "Day Tripper," differing with the majority view that "We Can Work It Out" was a more commercial song. As a result, the single was marketed as the first "double A-side," but airplay and point-of-sale requests soon proved "We Can Work It Out" to be more popular, and it reached No. 1 on both sides of the Atlantic, The Beatles' fastest-selling single since "Can't Buy Me Love," their previous McCartney-led A-side in the UK. A promo film was also made:
Incidentally "We Can Work It Out" is one of those rare, true Lennon-McCartney compositions. Again, from the Wikipedia entry:
McCartney wrote the words and music to the verses and bridges, with lyrics that "might have been personal" and thus a reference to his relationship with Jane Asher.McCartney then took the song to Lennon, and Lennon wrote the words and music to the middle eight.
With its intimations of mortality, Lennon's sixteen-bar bridge contrasts typically with what Lennon saw as McCartney's cajoling optimism.As Lennon told Playboy in 1980, "You've got Paul writing, 'We can work it out / We can work it out'—real optimistic, y'know, and me, impatient: 'Life is very short, and there's no time / For fussing and fighting, my friend.'"