Your engine sucks air which creates a vacuum. All air entering the engine normally passes through the Air Flow Meter which alows the computer controling your engine to make appropriate adjustments to make sure itruns smoothly with the correct mixture of air and fuel (and lots of other things, but I won't go into it).
If you have an air leak upstream of the air flow meter, (vacuum leak) then the computer is getting a reading of less air than is actually entering the engine causing unusual behaviour such as high idle, hunting idle, or rough/stalling idle.
May be as simple as a loose hose on the intake, or a crack in a hose, or as Joel (Doughnut) is getting at, a poorly sealing valve cover gasket.