Scientists have several theories to explain why some people react to sunlight that way. A common explanation is that their cranial nerves (in charge of sneezing) are connected with optic nerves (in charge of vision) for some reason; When the optic nerve is over-stimulated, for example, the pupil shrinks under the influence of light, it will trigger the cranial nerve.
Some researchers believe that people with allergies are more likely to sneeze in the face of sunlight. In one study, researchers first treated such people's allergies, and as a result, when they looked up at the sun again, fewer people sneezed. There is also a theory that sunlight stimulates facial nerves, which in turn stimulates nasal mucosa, leading to sneezing. So far, there is no accepted conclusion about what causes this symptom and why this feature remains. This symptom does not seem to have any benefits, but it will not cause other health problems.