The purpose is to match the amplifier input voltage to the voltage coming out of the head unit - so ideally, the amplifier won't clip before the head unit does.
Variable gain on an amp takes an input signal voltage and converts it to a certain signal voltage that the output stage of the amp cna use to make maximum unclipped power. Basically it allows you to match the output of the source unit (no two units have the same output voltage, there is no standard) to the needs of the amp.
That is the normal use of the term "gain" in car audio. The meaning of it in an audio engineering lexicon is amplification. Take a low voltage signal and make it into a high voltage signal. This "gain" in voltage is genserally expressed in dB or as a multiplier.