Maintenance mode allows you to put your site in a state which no anonymous visitors can access site content, aside from the maintenance message you specify and files in the file system which are not private. A site might be put in maintenance mode during development, to perform site maintenance, or as a security precaution during an attack.
Common methods of putting a side into maintenance mode are using the Drupal UI or drush.
Drupal UI
To put a site in maintenance mode, you must first have the permission level to do so, typically assigned to an administrator role.
Once you have logged into the site, you can turn maintenance mode on at path /admin/config/development/maintenance (the path is the same in both Drupal 7 and 8) by clicking the "Put site into maintenance mode" checkbox, then "Save configuration".

Drush commands
An alternative to the user interface is to use Drush. Ensure you have SSH access setup first.
Drupal 7 commands
Enable maintenance mode, then clear Drupal cache
drush vset maintenance_mode 1
drush cc all
Disable maintenance mode, then clear Drupal cache
drush vset maintenance_mode 0
drush cc all
Drupal 8 commands
Enable maintenance mode, then clear Drupal cache
drush cset system.maintenance_mode 1
drush cr
Disable maintenance mode, then clear Drupal cache
drush cset system.maintenance_mode 0
drush cr