We are often asked if it is possible to wake a sleeping MacBook or MacBook Pro with the lid closed and running on battery. Apple's laptops do not allow this behaviour.
If your MacBook wakes itself while the lid is closed, and while running on battery, the computer could be harmed. The harm could arise from being in a poorly ventilated environment – such as a laptop bag or within your luggage.
Over on AskDifferent, Luke experienced precisely what Apple's engineers are trying to avoid:
However now every so often i close the lid and mac goes to sleep and then it just randomly wakes up and stays awake. I didn't realized once and my mac spend few hours in its thick sleeve while running. I came home and I could smell burning plastic - aka. my mac melting itself. Luckily didn't catch fire. -- Luke
If your MacBook is connected to an external display, it can be used with the lid closed. This is because Apple's engineers can make the assumption your Mac must be on a desk, or at least not tucked away in your bag, if a display is connected.