I'm looking at an early morning (7 am) flight out of Munich Airport. What's the best, safest choice for getting to the airport? If I got there the night before, would I be allowed to stay in the airport overnight? Would it be very unsafe to take public transportation there in the early morning, around 4 am?
Sleeping: Sleepinginairports
Munich ranks fairly well.
Public transport: relevant page on the Munich airport homepage OR do a Thorntree-search OR wait for abalada OR soemone else
Yes, it's safe.
DB timetable
From: Munich
To: MUC airport
Single ticket is EUR 8,80.
It is not unsafe at all to take public transport there in the early morning in Munich. It's one of the safest big cities on the planet.
There are a number of hotels and hostels next to the Hautpbahnhof (main railway station).

There is a hotel right next door to the airport. I have no idea what it costs and I don't remember it's name as I stayed at the Sheraton Munich, which is about a 10 minute shuttlebus ride from the airport. I have to warn you that Munich doesn't seem to really have much cheap accomodation, not as far as I could tell. Munich itself is quite far from the airport and it's a long ride on the subway - maybe 40 minutes if I remember correctly. The subway may not be open at 4 AM - I have no idea. There are a few hostels in Munich, but I'd advise booking in advance as I don't think there are very many and there may be a lot of competition for rooms there.
Most airports aren't great places to spend the night. Will they let you sleep on the floor there? Probably, but it won't be comfortable.
Kempinski Hotel Airport Munich
but I guess not really in a price range acceptable to the OP.
some hostels next to the main railway station
wombat's
Euro Youth Hotel
Jaeger's