Like most Christian holidays, Candlemas is basically an old Pagan tradition with fancy new Jesus decals slapped on. While the holiday is officially devoted to the purification of the Virgin Mary, in practice it's the due date to throw out your Christmas tree and start thinking about Spring while watching furry critters emerge from their holes.
Germans had Candlemas traditions similar to Groundhog Day--except they used hedgehogs--and when they immigrated to America they tossed out all the religious parts of Candlemas, keeping only the fun "waiting around a varmint-hole and drinking" stuff. The groundhog was chosen since it hibernated in the winter, sort of looked like a hedgehog--which aren't native to North America--and presumably because too many people got eaten when they tried it with bears.
But why does the groundhog seeing its shadow and returning to its burrow mean six more weeks of winter? Well there's actually some meteorological truth to it. A winter day sunny enough to allow a rodent to see his shadow is likely to be colder than average since cloud cover actually insulates the earth. In other words, there's nothing mystical going on here, Mr. Groundhog just went back inside because he was freezing his furry little ass off, and if it's still too cold for him there's probably more winter coming.
That, and there's a town in Pennsylvania that really, really needs the tourist dollars.