Human beings evolved to move. Our bodies, including our brains, were fine-tuned for endurance activities from our history as hunter-gatherers. There is consistent findings that the brain works better after exercise, but discovering why has been more difficult.
Exercise changes both the number of neurons in your brain and how they communicate, as well as becoming more sensitive to the world around us. It has been suggested through studies that if the brain isn’t challenged or stressed enough it may reduce capacity to save energy as a response to inactivity. Read more in these two articles: