Some people's eyes don't shut when they sneeze, but most people's do. So if there's no concern that our eyes will pop out of our heads, then why do they close automatically?
You might think the eyes close as a defensive mechanism -- to keep all those projectile germs and bacteria out of the eye. But that's unlikely to be the case since the force of a sneeze sends the particulates away from the face, not toward it.
The more likely reason that eyes close during a sneeze is for no reason. It's just an involuntary reaction with no real purpose. The eyes may close during a sneeze for the same reason your leg kicks out when your knee is tapped. It's not just the muscles in your eyelids that react during a sneeze. Many muscles all over your body react. For example, many people with stress incontinence experience urine leakages when they sneeze -- the result of those muscles tensing and releasing involuntarily.
So it's a pretty disappointing conclusion: The body forces your eyes to shut during a sneeze, but there's no real purpose for this action. Instead, it's a reflex that may have had a purpose at one time, but serves no function now.