HTTP authentication is generally used to restrict access to site, it is generally used if site is intended for specific user groups or to restrict access to development server.

Drupal 8 provides contributed module named shield to restrict access. You can enable HTTP authetication using the following steps

  1. Download shield module from https://www.drupal.org/project/shield and place it in modules directory
  2. Login to your site as Admin
  3. From module list "admin/modules" enable "PHP Authentication shield"
  4. Goto "Admin > Configuration > System > Shield"(admin/config/system/shield)
  5. Add desired user name and password and save the configuration

Note: As of now Drupal 8 basic_auth module and shield module cannot co-exist together
https://www.drupal.org/node/2811173

You can find more Drupal 8 details here