When mucus dries in the eyes, it can leave behind this sludgy substance. Some people refer to it as having "sleep" in the eyes.
Mucus helps protect the eyes from specks of dirt, harmful chemicals, and other foreign materials. Eye boogers are harmless, but changes in discharge from the eyes can give clues to health concerns someone may have.