First of all, it's not called "Mondschein" — that is (like most of the popular titles of Beethoven sonatas) a much later romantic invention. People should forget about it. Beethoven published it as "Sonata quasi una fantasia per il clavicembalo o il pianoforte" (the same title as op. 27, 1, a quite different work).
And it's not "part of something bigger". If it was, it wouldn't be a sonata. Don't get confused by the opus numbers, op. 27,1 and 27, 2 were simply published together.
The dedication is "Der Gräfin Giulietta Guiccardi gewidmet", but that means less than it seems; originally Beethoven had intended to dedicate another, much easier piece to her, but circumstances forced to change the dedications at the last moment. So he probably didn't write it "for" her; unlike earlier sonatas (Mozart's, for example), Beethoven's sonatas were not written with amateur players in mind; they were written for virtuosos (like Beethoven himself).
Yes, Beethoven had a crush on her (nothing more), but he was well aware that marriage was out of the question -- for the simple reason that she was a "Gräfin" and he was a simple bourgeois ("leider ist sie nicht von meinem stande"). Nobody saw anything unusual in a girl in her mid- to late teens marrying a man in his thirties, but a bourgeois marrying a noblewoman would have been a major scandal.