That is because with the MAF connected, the computer is being told exactly how much air is entering the engine. If you have a vaccum leak the engine computer will have the incorrect information since you are either losing boost, or losing intake air.
The engine will fight with itself between proper mixture, and maintaining idle, tweaking this to get proper mixture, then tweaking that to fix idle, then having to tweak that to fix mixture... and on and on causing the flaky idle you see.
Disconnect the MAF and the Engine computer doens't look for a reading. Instead it uses a default value and guesses at the rest, simply using the IAC to maintain idle. Since it doesn't have the MAF to report something different, it assumes all is well.
You've got a vaccum leak somewhere. THere is a FAQ entry for tracking down vaccum leaks.