What is a GFCI?
A ground-fault circuit interrupter, or GFCI, is a device used in electrical wiring to disconnect a circuit when unbalanced current is detected between an energized conductor and a neutral return conductor.  Such an imbalance is sometimes caused by current "leaking" through a person who is simultaneously in contact with a ground and an energized part of the circuit, which could result in lethal shock.  GFCIs are designed to provide protection in such a situation, unlike standard circuit breakers, which guard against overloads, short circuits and ground faults.  It is estimated that about 300 deaths by electrocution occur every year, so the use of GFCIs has been adopted in new construction, and recommended as an upgrade in older construction, in order to mitigate the possibility of injury or fatality from electric shock.
 History                   
See a chart showing GFCI location history!

The first high-sensitivity system for detecting current leaking to ground was developed by Henri Rubin in 1955 for use in South African mines.  This cold-cathode system had a tripping sensitivity of 250 mA (milliamperes), and was soon followed by an upgraded design that allowed for adjustable trip-sensitivity from 12.5 to 17.5 mA.  The extremely rapid tripping after earth leakage-detection caused the circuit to de-energize before electric shock could drive a person's heart into ventricular fibrillation, which is usually the specific cause of death attributed to electric shock.

Charles Dalziel first developed a transistorized version of the ground-fault circuit interrupter in 1961.  Through the 1970s, most GFCIs were of the circuit-breaker type.  This version of the GFCI was prone to frequent false trips due to poor alternating-current characteristics of 120-volt insulations.  Especially in circuits with long cable runs, current leaking along the conductors’ insulation could be high enough that breakers tended to trip at the slightest imbalance.  
Since the early 1980s, ground-fault circuit interrupters have been built into outlet receptacles, and advances in design in both receptacle and breaker types have improved reliability while reducing instances of "false trips," known as nuisance-tripping.
Modern Requirements

The 2020 NEC 210.8 (A)  and the 2021 International Residential Code (IRC) E3902  contain similar additional updates relevant to GFCI use, as well as some exceptions for certain areas (follow the two preceding links to view exceptions):

All 125-volt through 250-volt receptacles installed in the locations specified in 210.8(A)(1) through (A)(11) and supplied by single-phase branch circuits rated 150 volts or less to ground shall have ground-fault circuit-interrupter protection for personnel.

  1. Bathrooms
  2. Garages and also accessory buildings that have a floor located at or below grade level not intended as habitable rooms and limited to storage areas, work areas, and areas of similar use
  3. Outdoors
    Exception to (3): Receptacles that are not readily accessible and are supplied by a branch circuit dedicated to electric snow-melting, deicing, or pipeline and vessel heating equipment shall be permitted to be installed in accordance with 426.28 or 427.22, as applicable.
  4. Crawl spaces — at or below grade level
  5. Basements
    Exception to (5): A receptacle supplying only a permanently installed fire alarm or burglar alarm system shall not be required to have ground-fault circuit-interrupter protection.
    Informational Note: See 760.41(B) and 760.121(B) for power supply requirements for fire alarm systems.
    Receptacles installed under the exception to 210.8(A)(5) shall not be considered as meeting the requirements of 210.52(G).
  6. Kitchens — where the receptacles are installed to serve the countertop surfaces
  7. Sinks — where receptacles are installed within 1.8 m (6 ft) from the top inside edge of the bowl of the sink
  8. Boathouses
  9. Bathtubs or shower stalls — where receptacles are installed within 1.8 m (6 ft) of the outside edge of the bathtub or shower stall
  10. Laundry areas
    Exception to (1) through (3), (5) through (8), and (10): Listed locking support and mounting receptacles utilized in combination with compatible attachment fittings installed for the purpose of serving a ceiling luminaire or ceiling fan shall not be required to be ground-fault circuit-interrupter protected. If a general-purpose convenience receptacle is integral to the ceiling luminaire or ceiling fan, GFCI protection shall be provided.
  11. Indoor damp and wet locations
Testing Receptacle-Type GFCIs
Receptacle-type GFCIs are currently designed to allow for safe and easy testing that can be performed without any professional or technical knowledge of electricity.  GFCIs should be tested right after installation to make sure they are working properly and protecting the circuit.  They should also be tested once a month to make sure they are working properly and are providing protection from fatal shock.
To test the receptacle GFCI, first plug a nightlight or lamp into the outlet. The light should be on.  Then press the "TEST" button on the GFCI. The "RESET" button should pop out, and the light should turn off.
If the "RESET" button pops out but the light does not turn off, the GFCI has been improperly wired. Contact an electrician to correct the wiring errors. 

If the "RESET" button does not pop out, the GFCI is defective and should be replaced.

If the GFCI is functioning properly and the lamp turns off, press the "RESET" button to restore power to the outlet.
Note!  When testing for GFCI protection of electrical circuits by activating the trip button on a 3-light testing device, the inspector may then be unable to locate the GFCI outlet controlling the circuit to which he has shut off power. Affected outlets are sometimes in another part of the home or hidden behind the occupant’s belongings. Using the test button built into GFCI outlets will prevent this problem.
Recognizing GFCI Breakers
GFCI breakers are easy to recognize by the additional white conductor and the label.