Short answer: We don’t know. Where does any creative artist get the idea for any of his creations?
So much for that. We’ll never know how the thought welled up in Beethoven’s mind that it would be a cool idea to have a choir march out at the end of the fourth movement. We do know, however, that he had been interested for some time in creating new forms of music. He had already created a hybrid piano concerto/choral work in his “Choral Fantasy,” a 20-minute piece whose words and music are very much a precursor to the Ninth; Beethoven himself said in a letter that the symphony was “a setting of the words of Schiller’s immortal ‘Lied an die Freude’ in the same way as my pianoforte fantasia with chorus, but on a far grander scale.”