The nervous system works to keep your body in a state of balance. This is called Homeostasis.
Homeostasis is a condition of equilibrium inside the body or a cell. it is required to continuously update in its state as per the changes in the outside environment to keep the inside parameters constant. for example, maintenance of healthy blood pressure and internal body temperature.