As already stated, rebooting clears all temporary state and gives programs a chance to start anew, hopefully for the better.
Computer programs are complex. Any non trivial program has an exponentially large number of possible states. Programs are tested before being released, but there is just no way that all possible states can be tested, so every program has an exponential number of possible states that are potentially problematic.
Programs are built using libraries, which have the same underlying complexity and potential for bugs.
Libraries call lower level libraries and eventually libraries exposed by the operating system interface. The operating system is itself a collection of programs, each of them dedicated to operate a different piece of hardware (device or chip).
Every device or chip is in itself a little computer and has its own stack of programs, the firmware of the device.
it is programs all the way down, and at each step only a small subset of possible states is tested. And each little piece is developed by and large in isolation from the other ones.
Now, imagine that on an average computer you have at least a few hundred programs (processes) running at once. On a simpler device, you may have fewer, but still the vastness of the state space is mind boggling.
When you think about it, it’s a tribute to human ingenuity that we can get anything done at all between a reboot and the next one.