Scientists who carried out the study said the results indicate that doing simple tasks that allow us to daydream is key to solving trickier questions playing on our minds.
"Many influential scientific thinkers claim to have had their moments of inspiration while engaged in thoughts or activities not directly aimed at solving the problem they were trying to solve," said lead author Benjamin Baird, of the University of California, Santa Barbara.
"This study demonstrated that taking a break involving an undemanding task improved performance on a classic creativity task far more than taking a break involving a demanding task, resting or taking no break.
"The findings arguably provide the most direct evidence to date that conditions that favour mind wandering also enhance creativity."
The research, published in the journal Psychological Science, is likely to please school pupils and bored office workers who enjoy gazing out of the window but may not go down less well with teachers and bosses.
Einstein is believed to have begun his theory of relativity while he daydreamed about riding or running beside a sunbeam to the edge of the universe - after he was expelled from school for rebelling against rote learning.
Newton developed his theory of gravity after he happened to see an apple fall from a tree in his mother's garden in Lincolnshire.
Further back the Greek philosopher Archimedes shouted 'Eureka' when he stepped into a bath and realised the relation between the rising water level and the volume of his body that was submerged.
The study involved 145 people aged between 19 and 32 who were given two minutes to list as many unusual uses as possible for everyday objects. They were then split into four groups with one of the groups not allowed any break from the task. The other three groups were each given a 12-minute break during which some carried out a demanding memory task, some enjoyed complete rest and some did an undemanding task.
Those who did the undemanding task were found to be daydreaming a lot about personal issues or past or future events as a result of its ease.
All participants were then asked to return to the task of listing unusual uses for ordinary objects. When considering new items all groups did the same. But when considering the same objects as earlier, daydreamers improved their performance by 40 per cent while the other groups performed the same as before.
The researchers said the improved performance was associated with "a higher level of mind wandering but not with a greater level of explicitly directed thoughts about the task." They added that the "seemingly dysfunctional mental state" of daydreaming may "serve as a foundation for creative inspiration".
The authors suggested that we may unconsciously process thoughts while concentrating on another task but said more research is needed to explain more fully how this happens.