First of all, we need to differentiate a squint, in which the eyes do not look in the same direction, from deliberately squinting or screwing up the eyes to see more clearly.
The short answer is squinting changes the shape of our eye.

The long answer is the eye is a complicated organ! Squinting allows us to see better in two ways – by changing the shape of the eyes, and by letting in a limited amount of light. Light enters the eye through the pupil and travels to the lens. The lens uses muscles in the eye to change shape in order to focus the light on the retina, a sensory area at the back of the eye. People have slightly different shapes of eyes. If the eye is not perfectly round, the light coming in through the lens will be focused slightly off center causing blurry vision.

When we squint we are actually changing the shape of our eyes slightly, and by doing so the light is focused correctly. Light traveling into our eyes comes from many different angles and must be focused onto a single area at the back of the eye. When we squint there is less light entering our eyes, and the light that is entering only comes from a limited number of directions since our eyelids are covering up the rest. Now only a few beams of light need to be redirected in order for us to see clearly.