In PLC Digital Input Module, the optoisolator isolates the internal components of the PLC and the external input devices.
Diode (D1) provides protection during switching from inductive devices.