That is precisely what it was used for: to protect from the harsh rays of the sun. These rays are mostly dangerous in the deserts, which is where the umbrella originated, around 1400 B.C. in Mesopotamia.
The umbrella was originally an extension of the fan: people figured if this thing can generate a breeze, why not expand it into a cone shape and use it as a sun shield? However, that they did.
The Greeks and Romans considered it very unmanly, and so the umbrella became associated with femininity. Even when it rained, men bravely got soaked.
This ridiculousness lasted until around 1750, when Jonas Hanway, a determined British gentleman insisted on carry one, to the boos of his peers and passersby. He sure saved on cab fare and suits so he could not be worried with the jeers.
Eventually after thirty years of this perseverance, idle British men needed some purpose in life, even it was to prove their masculinity of an accessory. More and more brits joined Hanway in carrying an umbrella, and now the men do not have to worry about being jeered at, everyone carries an umbrella.
Source: 101 Inventions that Changed the World by Joshua Coltrane – 1995