“Sand” and scratchy eyes are not cause and effect but are both the result of irritation.
The so-called sand, or “sleep” that builds up at the corners of the eyes is actually dried mucus.
If the eyes are irritated for any reason, pollution or dryness, for example, more mucus is secreted, and the longer the eyes are exposed to the irritant over the course of the day, the more mucus builds up.
Overnight, the eyes themselves stay fairly moist with tears, because the lids are closed, but the mucus collects in the corners and dries out.