Oscillators are used to provide clock to the microcontroller. In a microcontroller or microprocessor, every instruction is executed in synchronization with clock. It provides timing for different operations in a microcontroller.
It is not necessary to use crystal oscillators, in fact we may use other oscillators. It depends on the application.
Crystal Oscillators are preferred because of the following reasons :
> Can be used for high frequency generation
> Low Cost
> Small in Size
> Low Power Consumption
Nowadays many microcontrollers have internal RC oscillators, it can be used if precision is not important. Usually these internal RC oscillators cannot generate higher frequency clocks.