Such a condition is probably an inflammatory response to the irritation of having the eyes open and exposed to the drying air.
The effect is common knowledge and a clear symptom of sleeplessness but has not been completely studied.
Eye lubricants and tears dry in the air and may form scratchy particles. The skin around the eyes is pretty loose, and it can gather fluid fairly easily, so the swelling can be a sign of irritation. Redness, a result of capillary dilation, is another sign of irritation.
In some cases, the condition might also be a manifestation of an allergy, especially one to mattress mites, microscopic arachnids that infest many people’s bedding. In such cases, a water bed might help.
A night of sleep helps cure the condition by protecting the eyeball. Even if you can’t sleep, keeping the eyes shut will help.