Daydreaming is your brain’s way of taking time out to update its narrative.
One of your brain’s tasks is to construct and maintain your master story, the story you tell yourself about who you are, how all the pieces of your world fit together, what you aspire to and care about, etc.
The actual thread of experience of your life tends to be rather unstructured. The universe, it turns out, doesn’t care about your story. But you care very deeply about your story, since it gives meaning and definition to your life.
That’s why every now and then, when your attention isn’t taken up with what’s going on around you, your brain checks out of monitoring the current thread of experience and devotes its resources to trying to make sense of the flood of experience in a way that fits in with the master story. It will imagine the possible plot twists that might lie ahead; it will obsessively replay encounters with others; it will rehearse the various roles you play in life. Experiences that seem relevant to the story are churned over and over; those that don’t fit in well (or contradict it) get ignored.
Daydreaming is the editor of your story at work.