Squinting is an involuntary reflex that we often cannot control. When we expose our eyes to bright light, our autonomic system takes over and causes the lateral rectus muscles of our eyes to contract. By doing this, we reduce the amount of light that can enter our eyes at once, thereby avoiding the discomfort or painful sensation that comes from seeing too much bright light at once. This action results what we know as squinting.
Besides reducing the amount of bright light entering our eyes, squinting also has two other important purposes. The first of these being a way to temporarily improve visual acuity (or the sharpness of your vision). For instance, when trying to see something far away or read a fine print, many of us tend to squint in order to see better. Squinting actually does give the momentary ability for us to see better since we reduce the amount of surrounding unfocused light from reaching the retina and interfering with our ability to make out a fine print. However, when we stop squinting, the fine print often becomes blurry again since the peripheral light rays are entering our eyes once again and interfering with the focusing of the fine print light on our retina. This reduction of unfocused light in the periphery leads to less light overall focusing on our retinas, which allows the retina to greatly increase the sharpness of our vision.
The final purpose of squinting has to do with reducing the amount of pain our eyes experience in the event of a foreign body, like dirt or even an eyelash, getting stuck in our eyes. In response to detecting the uncomfortable substance, our eyes tend to involuntarily contract (or squint) in an effort to protect the cornea of the eye and minimize damage to the eye. This is why it is often hard to keep our eyes open when we do get an eyelash or dirt stuck in our eyes.