Pārvati (Shiva's wife) wanted a child. With her husband not there, being a goddess and all, she was able to create one from her own body. She was going to take a bath and told her new son to stand guard at the door and let no one, no matter who it was pass, to protect her privacy. As Murphy's Law would have it, Shiva comes home at that very time. Shiva and Ganesha did not know each other as father and son, Ganesha refused to let Shiva pass, which infuriated Shiva beyond belief because he wanted to see his wife, whom he loved dearly and missed during his retreat. Shiva took his trishula and lopped off Ganesha's head. Pārvati was furious that Shiva would commit an act of violence, much less kill his own son (whom, in Shiva's defense, he didn't know). So Pārvati would have nothing to do with Shiva (if you get my drift
) until he replaced the boy's head. Shiva sent his associates to bring back the head of the first being they found sleeping with its head pointing north (don't ask me why... I only tell the stories I don't make them up
) which happened to be an elephant. That's why Ganesha has an elephant's head, but there's a lot more symbolism to it that I don't know of off the top of my head (no pun intended). One has to admit that Hindu purānic stories are nothing if not colorful (though digging deep, one finds a moral or lesson in virtually every one of them).