Hercules
Hercules was just in the beginning of his famous Twelve Labors, working on the second one, when he encountered the giant crab while trying to destroy the fearsome hydra, a multi-headed serpent.
Jealousy
Hera, who was jealous and upset that Hercules was the offspring from an affair between her husband Zeus and a mortal woman, sent the crab to try to distract Hercules as he did battle with the hydra.
Crab Attack
The crab came out of the swamp where Hercules engaged the hydra and grabbed his foot, but Hercules unceremoniously crushed it beneath his heel, killing it.
Crab's Reward
Hera felt compelled to reward the crab for its brave sacrifice, so she placed it in the sky, but made sure it had no bright stars since it did fail so thoroughly.
Other Links
Other constellations linked to the Hercules myth include Hydra, Sagitta, Crater, Lyra, Aquilla, Serpens and Centaurus.