George Martin made it while the Beatles were at lunch and wanted something Baroque sounding, and while he couldn't play a harpsichord speed, he could play the piano at half the speed and an octave lower. When sped up, it gives us the sound we hear in the song.
J.S.Bach's Prelude and Fugue No. 1 in C major, BWV 846: http://www.youtube.com/watch?v=RqMgCYUJBuo (harpsichord, first 2 minutes) http://www.youtube.com/watch?v=0KQW2YnCUrE (piano, first 2 minutes)
"Fringe" theme: http://www.youtube.com/watch?v=c4Vvs_JAh04
edit: As crash7800 explained, "Fringe" theme is not based on this Bach's piece. They only share similar structure. It's so fun! :)