Why do we need to restart modems/routers?
A modem/router is a very small computer that has a very limited amount of memory and processing power compared to a normal computer. Your modem/router performs a lot of complex tasks to make sure that the right data gets to the right computer at the right time as efficiently as possible.
Like a computer, there are many different problems that can occur many of which can be fixed by restarting the device.
A technical explanation
Over time many of the connections opened in the modem/router, to send data to and fro, can stay open for a while on the router consuming memory and /or using processor cycles. After a while (and perhaps even after certain operations) the modem/router may run into bugs or loops or operations that slow things down. As you push more data through a modem/router it can run out of memory, or encounter a bug that freezes the routers operating system, or even overheats the processor.
Imagine about a quarter of the way through a game of chess, someone makes an incorrect move which is not spotted by either player. Say they take another piece with their pawn by moving forward (rather than diagonally). Many moves later, one of the players realizes what has happened. Clearly the game cannot continue to an adequate conclusion if there was an incorrect move made (and once the incorrect move has been made we can assume that each move made after it was incorrect in some way), so the mistake needs to be rectified. The two options are either to reverse each move, taking us back to the mistake and rectifying it this way, or completely restarting the game. Each solution would lead to a satisfactory conclusion for the game, however completely restarting the game is more time efficient, more accurate and less onerous.
In a similar way, when you restart a computer or a modem/router, you are essentially allowing the device to restart the chess game to fix whichever mistake was made in the past.
In a chess game the person who made the error can be more careful next time & avoid the problem but a computer or modem/router (unlike a chess player) does not learn from this error so if exactly the same thing happens again, it will impair the router/modems efficiency again thus requiring another restart.
Sometimes your modem/router may need restarting "too often", this can sometimes be caused by a temporary internet connectivity issue but also by a variety of other issues including devices within your network not performing correctly right through to perhaps your modem/router or another device being faulty. Some people put an electronic timer on their modem/router and other electronic devices to turn them off and on again on a daily basis. We would regard anything more often that this as unusual and if your modem/router was requiring to be restarted too often for reasons other than temporary internet connectivity issue further action beyond the troubleshooting steps below may need to be taken.