The main function of a lens hood is to prevent stray light from entering the lens. This helps control lens flare and can help a little with the haze you get when your lens is pointed too close to the sun. They have the added bonus of helping to protect the front element of your lens from bumps and drops when you're using them.
When they cause problems... with longer lenses the hood can get in the way of some flashes, especially the on board flash. Also if you're intentionally trying to get the back lit sun kissed, hazy flare look that's so trendy right now you won't want a hood on there.
Do you need to use one... if you're shooting outdoors during the day they're really helpful. Many of us will keep the hood on the lens even when we don't need it for protection. But it's not an absolute must have to make a great image.