Optically isolated inputs use a device called an optocoupler. An optocoupler consists of a light emitting diode (LED) that gets lit up by an externally applied current, and a photo-transistor that turns on when illuminated by the LED. Because the two need not be electrically connected, there can be a great deal of voltage difference between the LED and the photo-transistor. This provides isolation between the external sensor circuit and the controller circuitry. That isolation can provide an electrical safety barrier or reduce electrical noise coupling.
Typically an optically isolated input will have two input wires. The external circuit (sensor) must apply the right voltage between those wires to turn on the optocoupler. Often the controller will provide a convenient voltage source and configuration options so the inputs can be used with NPN or PNP sensors or dry contacts.
While optically isolated inputs may provide technical benefits in noise reduction and safety isolation (if used correctly!) they tend to add significant cost.