What is the XTAL clock used for in an 8051 microntroller?
The MCU processor requires a clock to do (almost) anything. Aside from perhaps the RST input which is probably partially asynchronous, everything happens after some number of clock edges. 

None of the code will run without a clock, so, for example, the timer module cannot be set up without a clock and some code. 

The 8051 is a rather old microcontroller and requires an external clock (either a pulse train or there is an internal oscillator which can use a bare crystal). Some relatively newer processors may have an internal RC clock, as an option or perhaps as the only clock source.