Monsters can only spawn in complete darkness at a light level of ≤0 (caves, unlit areas). Moonlight at night counts as a light source and therefore prevents monster spawning.
This only applies to the Overworld. The Nether and the End are not affected — monster spawning there follows normal rules. Slimes in swamps (or in superflat worlds) are also unaffected.
