Ganesha first appeared in Hindu literature sometime around the 4th to 5th century. He is an easily recognizable deity, whose most notable role is being the remover of obstacles, but he also places obstacles in the path of those needing to be checked. He is also associated with intelligence, wisdom, prosperity, protection, and learning.
There are several stories as to why Ganesha has an elephant head. My favorite version is the one that tells of him guarding the door to where his mother, Parvati, was resting. His father, Shiva, who had been away since before Ganesha was born, returned one day to see his wife. Not knowing who Ganesha was when he saw him standing guard at the doorway, he pulled out a sword and cut off his (human) head when Ganesha tried to stop him from entering the home. When Shiva went inside to see his wife, she exclaimed to him, "Did you see your son Ganesha on your way in?"
Shiva was horrified at what he'd done, so before his wife noticed his mistake, he told his army to go out and find the first head they could, and bring it back so it could be attached onto Ganesha's body. Taking Shiva's words literally, the first creature they found was an elephant. They cut off its head, brought it back to Shiva, stitched it on, and wha lah, everything is fixed.
I don't know what Parvati's reaction was, but I can't imagine she didn't notice...
You can see more images of Ganesha here