A lens hood has a couple different jobs
You cameras lens hood can help to shield the front of your lens from the sun rays, or other bright unwanted light, from directly hitting the front lens element and scattering the light creating sun/light flares, those are the rainbow colored streaks and hexagonal colored shapes created when the sun reflects off the aperture.
Another job of the lens hood, or shade is it helps to prevent, minimize any damage to the front of the lens from the elements or in my case from slipping in the mud while out on an outdoor photo-shoot.