I have a theory that insomnia is a necessary part of human evolution. It is frustrating to be too wakeful to sleep, and too sleepy to get up an do anything useful, but at least, being wakeful, you are aware of your surroundings. Hence my theory. It goes like this: In times and places where groups of humans, tribes, say, have to be on their guard against predators and enemies, it is useful to have people in the group who are not asleep. Sometimes it is not feasible to have them fully on guard, but it is useful to people who, being unable to sleep, are aware of their surroundings, alert to anything amiss, who can raise the alarm when danger approaches.
It is amazing how the fact of being social animals has effected human evolution. Consider the phenomenon of grandmothers, women who have lived beyond child-bearing years and yet are necessary parts of the tribe. Consider the childless 'uncles' and 'aunties', all necessary to to contribute the raising of the next generation to keep the tribe going. Have you noticed how, as you get older, insomnia becomes more of an issue? Guess who's awake for the sick and the restless, the children with fevers and so on. Guess who is likely to be semi on guard?
It's not much comfort when you know that around dawn, when others are stirring, you finally start to fall back to sleep but mustn't because of the clock, but in another time you would have been the hero.