How can I keep a macbook running when the display is closed?
If you have an external display, then just closing the lid generally works.

Apple calls this "closed clamshell" mode or closed display mode.

But if you only have the macbook, and you want to be able to close the lid without sleep, for instance to move it from one class to another at school without having to use sleep etc, then it's more tricky.

One option it to enable internet sharing in Preferences, this requires the OS to stay running in case anyone wants to connect, but it does potentially leave you open to unwanted connections.

Another way is to run an app like NoSleep to do the hard work for you, it's free - check the link.

But there is no simple setting for doing this built into the OS.