What is the purpose of the 7805 input capacitor?
The input capacitor reduces the impedance of the power feed as seen by the regulator.  This reduces input voltage fluctuations that occur as a function of current demand fluctuations, which the regulator has no control over.  The regulator can do a better job of keeping the output steady when the input is steady.

The regulator electronics are specifically designed to keep the output steady with the input varying over a wide range (that's the point of a linear regulator), but no such circuit is perfect.  Note the input regulation spec in the datasheet.  That tells you how much input variations are attenuated to the output.  However, that is usually at DC.  As the frequency of input variations goes up, the active circuit becomes less effective at attenuating them to the output.

Fortunately, a capacitor has lower impedance at higher frequencies, thereby reducing the voltage fluctuations due to current fluctuations at higher frequencies.  The capacitor does a better job as the active circuit does a worse job.  Another way to think about this is that the capacitor together with whatever impedance there is in the power feed to the regulator form a low pass filter.  This filter reduces the high frequency voltage fluctuations that the active circuit is less good at dealing with.