I have not used any keyboard with optical switches, but several decades ago I have used keyboards with hall sensors, which had a superb quality and reliability, much better than anything that I have used later.
Sadly, I had to abandon the first keyboard that I have used with computers owned by me, which had Hall sensors, because it was not IBM PC compatible (its origin was in some DEC-compatible video terminal and I had used it with a Motorola MC68000 based PC, which I have replaced with a PC/AT clone, for which I had to use a compatible keyboard, of much lower quality).
Otherwise, I am certain that it would have remained perfectly functional until today, unlike the many keyboards that I had to replace since then, when too worn out.
Their first keyboards actually used optical switches, and from everything I've heard were less reliable, and tracking precision was much worse than with the magnetic switches
The reason is that the optical components are all plastic and that plastic degrades (yellows) over time due to exposure to UV light (which is all around us). They should last about 10 years in a normal office environment but I've heard reports that they're really only lasting about ~5 years.
Admittedly, five to ten years is probably fine. Just the gunk buildup in a normal keyboard is enough that most people would rather just buy a new keyboard than deal with cleaning it out. Even if the switches are hot-swappable! It really is a tedious thing that requires a lot of time and special tools (to do it right). Some keyboards and switches can only be hot-swapped a few times before they start to become wobbly/loose anyway.
I designed my Void Switches (https://github.com/riskable/void_switch) because I was sick of replacing keyboards so often (my fingers are like salt-water-drenched hammers, apparently). I also wanted a keyboard that was super easy to clean! Check it out:
Every few weeks I take the top of my keyboard off and clean it out in sink with soap and water (and a scrub brush made for dishes). Been typing on this AHEK-95 for just over three years now so I've probably washed it at least 50 times and it's still working great!
NOTE: This is NOT patented technology! Logitech, Wooting, and all other keyboard manufacturers: WTF are you even doing‽ Copy my design already! I'll even help you do it! Make a keyboard that lets end users 3D print replacement switches/parts and you'll OWN THE MARKET (until others hop on board). What are you waiting for‽