Can anyone tell me what is the purpose of diodes at the output of a chip?
Do you mean the 8 diodes going to Vcc and GND?

They are clamping diodes for over- and undervoltage protection of the output pins.

They are there because inductive loads (e.g. stepper motor coils) create a voltage if suddenly turned on or off.