Unlike many pop songs, whose clear chord progressions and distinct instrumentation keep the melody rather clean, "I Am the Walrus" is one big musical jumble. That jumble comes not from super-complicated keys or chord changes, though; instead, the song's sonic chaos results from the inclusion of dozens of different voices, instruments, and sound clips throughout. The mix is deliberately congested.
Otherwise, "I Am the Walrus" is a fairly simple piece of music. The song pretty much stays in the same key (A Major) throughout, and while the harmony sometimes skews into other random keys, it holds its initial melody consistently. In his very detailed and interesting musical breakdown of the song (which you should definitely check out), Allan W. Pollack says:
Many times I've told you how wherever you find the Beatles at their most far out you also find them, under the surface, operating on their most classical instincts. So don't be fooled here: no matter what else you may respond to in this wonderfully outrageous song, you should acknowledge the extent to which it ultimately weighs in as a (granted, extremely stylized and abstract) talkin' blues number. In this regard I'm thinking not just of the patter style declamation of the words, but also of the formal use of phrases in groups of three, and the prominent exposure given to the V-IV-I progression, especially in context of a song whose harmony is otherwise quite out to lunch. (Source)
The V to IV to I progression that Pollack mentions is a very common musical trick that's used by composers to make a song sound good; we'll try our best to break it down for you.
Basically, every key (ABCDEFG) has eight notes that go along with it; in the case of "Walrus," the notes go exactly in alphabetical order because they start with A. The Roman numerals denote other keys within the main key, and capitalized roman numerals signify a major key. In the key of A Major, the fifth note of the scale (V) is E, and the fifth note of any major key needs to be major itself. Same goes for the IV chord, in this case D Major. A chord progression (playing several chords together) that makes any combination of these three main chords, I, IV, and V will always always sound right to your ear…whether or not you're totally following this explanation.
In fact, that V to IV to I progression just sounds good, sounds like music that makes you smile.
When you start throwing minor or diminished or seventh chords in, however, things get a little more complicated, and "Walrus" is a good example of a song that manages to achieve both simple I-IV-V progressions as well as random additional chords to spice things up. The first line—"I am he as you are he as you are me and we are all together"—follows an A-C-D-E-A pattern.
Okay, we already know A, E, and D, but what about C? C is the third note in A Major, and all third notes in major keys are played minor. So C Minor is the iii chord and throws a cog in the wheel of this nice little major chord progression, giving the song some interest right from the start. We're not going to break down every single chord the way Pollack does (like we said, you should check out his stuff in its entirety), but this happy major pattern broken by weird minor chords happens throughout the rest of the song.
And now for all the other sounds. Philip Norman, Beatles biographer, explains:
George Martin provided a wonderful score of sawing, grinding, bottom-register cellos, like sarcasm-made-melody, in which further insults, irony, and smut were hidden below the waterline. The Mike Sammes Singers, radio's coziest middle-of-the-road vocal group, were hired for the play-out chorus of 'Oompah-oompah, stick it up your jumper!' and 'Everybody's got one!' The multilayered sound effects even included a snatch of Shakespeare's King Lear lifted from a BBC Third Programme performance starring Sir John Gielgud (the scene where Oswald is fatally stabbed and cries, 'Oh untimely death!') It was clearly a song far beyond the powers of any four-piece rock group. (Source)
So, "Walrus" featured not only the voices of John Lennon and the rest of the Beatles, but also the Mike Sammes Singers and the actors in the BBC broadcast of King Lear. As far as instruments go, they had electric piano (which creates the opening sounds), guitar, bass, drums, violins, cellos, horns, and a clarinet—practically an orchestra.
The King Lear snippet just happened to be on the radio when John was flipping through stations at the famous Abbey Road Studios, where the band was recording. The scene that we hear during the "Everybody's got one" chant toward the end of "Walrus" reads as follows:
OSWALD: Slave, thou hast slain me.
Villain, take my purse.
If ever thou wilt thrive, bury my body
And give the letters which you find'st about me
To Edmund, Earl of Gloucester.
Seek him out Upon the English party.
O, untimely death! Death!
EDGAR: I know thee well: a serviceable villain,
As duteous to the vices of thy mistress
As badness would desire.
GLOUCESTER: What, is he dead?
EDGAR: Sit you down, father. Rest you.
A lot of people thought that the inclusion of these lines supported the "Paul Is Dead" conspiracy theory. Drawing on a collection of random evidence from Beatles songs (in Glass Onion John says "the walrus is Paul" and people thought, falsely, that the walrus was a death symbol), some theorists decided that Paul McCartney had been killed and replaced by a look-a-like.
Some people have seriously overactive imaginations.
All these crazy elements mixed together added up to one wild sonic mélange. "It actually was fantastic in stereo," Lennon later said, "but you never hear it all. There was too much to get on. It was too messy a mix. One track was live BBC Radio—Shakespeare or something—I just fed in whatever lines came in." (Source)