The reshape function is called once when the program first launches and everytime your window is reshaped/resized. The most important command is glViewport, which usually maps to the new size of the window.
It’s important as if you didn’t have this function, nothing would ever let your display function know when your screen size changes. If you don’t provide a reshape function, a default one is usually provided (at least in GLUT) which just changes the viewport. You can add in any of your own code that needs to be run when the window resizes but not necessary every frame render.