Building software automatically to ensure that no errors have been committed to source control that would prevent it being built. Especially useful when many people are changing the software independently. Usually done at night because of reduced commit activity, or because building takes a long time. Once built, the software may go on to be tested.
Concept
Building software refers to the processes of compiling, linking, packaging, generating documentation, and in general converting source code into something executable. Not all software will need all of those steps, but most of it will require some of them.
When many people are working on the same project, changes that might work perfectly on their own can combine to stop the software building. If that was only discovered when someone pulled the latest changes into their development copy, then they would have to stop work while the problems were solved. Automatic builds avoid this by taking the latest version, building it, and telling people when errors are found.
Nightly builds are automatic builds that are scheduled regularly, typically at night. Reasons for doing it then include errors being discovered before people start work in the morning, lower levels of changes, availability of hardware, and the time taken to build larger projects. Nowadays hardware is cheaper, software is more modular in construction, and it is often possible to increase the frequency of builds. Taken to the extreme, this leads to continuous integration, where builds are done one after the other. Some organisations are even able to build on every change, having enough resources that they do not have to wait for a build to finish before starting the next one.
This tag should be reserved for questions related to builds that run overnight or at a similar interval, not for ones that are specifically about continuous integration.
Tools
Many organisations use home-made build systems of varying levels of sophistication, but there are also a number of ready-made systems available. Most of them are designed for continuous integration, but also allow timed schedules. An typical example is Jenkins, and a list can be found at Wikipedia.