While exposure to sunlight has a number of health benefits including vitamin D production and improved mood, the intensity of direct sunlight can do significant damage to your eyes even when your eyes are closed. You should always wear sunscreen on your skin (minimum SPF 30) and limit your sun exposure so that you do not damage your skin with harmful UV rays. You should also wear sunglasses that are labeled as "UVA/UVB blocking" so that your eyes are protected from the damaging effects of the sun. It is important to only wear sunglasses with this level of protection, as wearing unprotected sunglasses will cause more damage to your eyes by allowing your pupils to dilate, thus exposing your eyes to additional UV rays.
Because your eyelids are only composed of a thin layer of tissue they do not provide adequate protection from the sun to allow you to face the sun directly. Even with high quality sunglasses you should still never look at the sun directly. At the back of each eye you have a collection of cells called the retina which is responsible for for absorbing light and transmitting a visual representation of the world to your brain. These cells are very sensitive to light and can be damaged by very bright or prolonged exposure to light.
If you are concerned that you have damaged your eyes by looking into or near the sun you should see either your primary care physician
or an ophthalmologist
for further diagnosis and management.