Optical is a legacy connection for people who haven't bothered updating their equipment in years. Might as well support composite video, too.
A lot of high-end audio equipment sold today still uses an optical connection.
It has the advantage of complete electrical isolation so things like ground loops cannot occur.
However you'll only find it used with 2 channel equipment, since the TOSLINK spec can only do lossy 5.1 audio.
Technically, it should be possible to do 5.1 or even 7.1 lossless over optical now, as newer optical devices can support up to 2 channels of 24/192 audio, which could be divided into 8 channels of 48kHz or 6 channels of up to 64kHz audio.
It doesn't surprise me that Nintendo have dropped the optical connection though, and for anyone who is using an older 5.1 receiver that does not support HDMI, it would be better to purchase an HDMI to analog audio converter box - not just for the Switch.
Most old receivers also have 5.1 analog inputs and that is and uncompressed connection, while optical is not.