- A neutral wire went bad - broken or loose connection somewhere in the circuit prior to this switch
- Either by accident (hey, if I touch this white wire to this bare wire, the light works again!) or on purpose (neutral and ground are connected, so they must be interchangeable) someone "fixed" the problem by connecting neutral and ground
This is very much against code. Neutral and ground are only supposed to be connected in one place, the main panel. There are some legitimate grandfathered exceptions with certain subpanels, but not for an ordinary switch or receptacle.
This is a really bad thing because not it messes up the way neutral and ground are supposed to work and it potentially puts actual current on to ground in unexpected places. Ground is only supposed to carry current in a fault, long enough to trip a breaker. (There are some exceptions with certain types of approved smart switches or other devices, but those involve very small amounts of current.)
The good news is that the problem is almost always in another junction box, and not a broken wire in the wall. The bad news is that means checking every junction box in the circuit between the breaker and this switch. You are looking for:
- Loose wires
- Loose wire nuts
- Loose screw connections
- Bad backstab connections
This last one is particularly nasty. A standard receptacle can legitimately be used to daisy-chain power to another location by putting one set of hot/neutral on the top connections and another set on the bottom connections. Even with screw connections, a wire could be loose and cause problems. But with backstab connections the problems are much more common. But builders will often use backstab connections to save a minute per connection...an hour of electrician's time per house...more profit!
If you find any serious problems - burnt wires/melted insulation, cracked receptacles, etc. then those need to be fixed properly. But if the problems are just loose wires, reconnecting them properly is all you need to do. Backstab connections can't be reused, so if you find a loose or bad backstab connection, move the wire to the screw and that should fix it.