UCSB brain researcher Jonathan Schooler has an intriguing theory about why our minds wander:
The regions of the brain that become active during mind wandering belong to two important networks. One is known as the executive control system. Located mainly in the front of the brain, these regions exert a top-down influence on our conscious and unconscious thought, directing the brain's activity toward important goals. The other regions belong to another network called the default network. In 2001 a group led by neuroscientist Marcus Raichle at Washington University discovered that this network was more active when people were simply sitting idly in a brain scanner than when they were asked to perform a particular task. The default network also becomes active during certain kinds of self-referential thinking, such as reflecting on personal experiences or picturing yourself in the future.
The fact that both of these important brain networks become active together suggests that mind wandering is not useless mental static. Instead, Schooler proposes, mind wandering allows us to work through some important thinking. Our brains process information to reach goals, but some of those goals are immediate while others are distant. Somehow we have evolved a way to switch between handling the here and now and contemplating long-term objectives. It may be no coincidence that most of the thoughts that people have during mind wandering have to do with the future.