Audio gating is the control of when and to what degree audio passes through a channel. In some cases, it is referred to as the noise gate. 
Imagine standing in front of a fence gate and whispering, “I want to come in.” Nothing happens. Then you yell, “I WANT TO COME IN” and this time the gate opens. The higher volume level is what opened the gate.  Gating devices in music production work in a similar way.
The primary uses for gating include: 
- The reduction of unwanted external sounds, such as noise of the street outside a recording studio
- The reduction of natural channel noises, such as the humming of an electric guitar signal
- As an effect that alters the time characteristics of a sound
- Threshold - The signal volume (in dB) that triggers when the gate is opened and closed.
- Attack - The amount of time (in ms) that it takes for the gate to be fully opened after a signal crosses above the threshold.
- Release - The amount of time (in ms) that it takes for the gate to fully close. The release is either triggered by the signal crossing below the threshold (if the hold time is set to 0), or by the end of the hold time period (if it is > 0).
- Hold time - The minimum time the gate is held open after a signal crosses above the threshold. The hold time is used to prevent chatter in highly fluctuating signals.
- Hysteresis/Return - Sets the difference (in dB) between the level that opens the gate and the level that closes it. The hysteresis is used to prevent chatter in highly fluctuating signals.
- Chatter - Chatter refers to the constant opening and closing of the gate due to high-speed fluctuations in the signal levels.
- Range/Floor - The amount of decibel reduction when the gate is closed. At -inf, a closed gate will mute the signal entirely. At 0, the gate is effectively bypassed.
Setting the threshold
The threshold is the "key to the gate". The higher the threshold, the louder the sound must be to open the gate. The lower the threshold, the more sound that will pass through when the gate is open.  Remember to take into account all of the future fluctuations in sound level when setting a gate's threshold. If a track has multiple parts, some louder than others, the gate may not act as intended in all of them. In this case, the track can be split into multiple tracks or automation can be used to adjust the threshold over time. To be safe, consider finding the 'ideal' threshold and then backing off a few decibels to account for future changes.
Setting attack and release
A gate that opens too quickly on a slower attack signal can produce a click sound. In this case, the simple solution is to extend the attack time until the click sound disappears. Consider very fast attack times for percussive instruments and slower times (10ms or more) fore everything else. 
The release time is key to a natural sounding audio decay. For noise elimination from a line, such as with an electric guitar, you want a natural decay which ends with the line noise being cut out. If using it as an effect then it would be set much faster. 
Setting the range
A gate set to the maximum range can create a dead sounding instrument. By setting a smaller range, some of the natural time characteristics (attack and decay) of a sound comes through. You might think of the range setting as a controlled fade.
Another of using a smaller range is that the gate does less work in a given time, which can lead to a less artificial sound. Using -90dB vs. -15dB is like driving zero-to-60 MPH versus 45-to-60 MPH.
There are a few approaches to reducing chatter that depend on personal preference and the device being used. The first is to increase the hold time (if available on the device). This guarantees that every time the gate is opened it will stay open for at least the hold time.
The second approach is to use the hysteresis/return to reduce the threshold for closing the gate, as compared to the threshold for opening it. In this case, the gate will only open and close quickly if the underlying signal does the same.
Using a hold time is simpler and effective in most cases. However, if the gate isn't responding to the signal in the desired way as a result of the hold time, consider trying the more precise hysteresis technique.
Improving drum articulation
Gating has the ability to accentuate transients by "trimming" off components of the sound that lacks punch. As a result, it's common to use gating to improve the articulation of drums and make them sound punchier. In the example below, the drums have a strong and punchy kick-snare beat, but it is obscured by the overbearing hi-hats:
With a little bit of gating applied, the drums sound significantly more punchy. They will also sit better in a mix with elements that would otherwise be competing for space and attention with the hi-hats:
Gating parameters used: threshold (-16dB), attack (2ms), hold (15ms), release (70ms), floor (-19dB)
Gating with sidechain
Adding a sidechain input to a gating device allows the gate to be trigger by an external sound. This can be used to make creative effects such as pulsing synths.
To accomplish this, first set up a ghost track. In the following example, a rhythmic hi-hat loop was used. Hi-hats make for great sidechain triggers due to their short attack and release times. In the gating device, enable sidechain and select the ghost track as the input.
The resulting output can turn a flat pad into a rhythmic one, as in the example below. The possibilities here are endless.
Gating parameters used: threshold (-28dB), attack (4ms), hold (4ms), release (4ms), floor (-35dB)
Gated reverb became an iconic sound in 1980's popular music after it was accidentally discovered it by Phil Collins and Peter Gabriel in a recording studio mishap.  Its signature sound defines songs such as "In the Air Tonight" or "Born in the USA", and it remains popular in modern pop, rock, synthwave, and other genres.
Gated reverb is typically applied a snare drum, but can be used creatively on any number of sounds. It is accomplished by setting up a simple effects chain that places reverb after the original sound, and a gating device after the reverb. The following examples show the difference between a simple kick-snare pattern with and without gated reverb on the snare:
Parameters used: threshold (-30dB), return (2.67dB), attack (1ms), hold (20ms), release (30.7ms), floor (-40dB)