While we sleep, our eyes can dry out due to a lack of tear secretion. If our eyes are dry or were exposed to allergens or irritants, they produce a mucous substance to soothe the ocular surface. This mucous can look like pus but is not infectious. It can collect on the eyelids and even dry and become crusty.
By placing a warm, moist wash cloth on the eyelids for a few minutes, this mucous can then be wiped away safely.
If this is a regular problem, you may benefit from lid hygiene techniques discussed on the dry eye treatment page.