Why does turning it off and on again actually work?
Because it discards accumulated state and returns the system to a configuration that was tested and known to work.
What builds up while something runs:
Memory problems. Memory leaks occur when a program allocates memory and fails to release it. Over hours or days, available memory shrinks, the system starts swapping to disk, and everything slows. Memory can also become fragmented, so large contiguous allocations fail even when total free memory looks adequate.
Resource exhaustion. Programs hold file handles, network sockets, database connections and locks. Poorly written code fails to release them, and eventually the system hits a limit and refuses new ones.
Invalid state. This is the deepest cause. Software has an enormous number of possible internal states, and developers can only test a fraction. A rare sequence of events — an interrupted update, a dropped connection at the wrong moment, a race condition — leaves the program in a combination nobody anticipated and no code handles. There is no recovery path because nobody wrote one.
Stale caches holding data that no longer matches reality.
Hardware in an unexpected state, particularly network chips, USB controllers and graphics hardware.
Why restarting fixes all of it. Startup is the most tested code path in any system — every user executes it every time. Restarting discards all accumulated state and re-enters a configuration that has been exercised millions of times.
Why it is unsatisfying: it fixes the symptom without identifying the cause, so the problem returns. If something needs restarting regularly, that pattern is itself the diagnostic information.
Not all restarts are equal. A full power cycle — off, unplugged for 30 seconds, on — clears hardware state and capacitors in a way a warm reboot does not. On Windows, Fast Startup means "Shut down" is really hibernation; "Restart" performs a genuine reboot, which is why Restart sometimes fixes what shutting down does not.