the Tale of Cancer
Heracles' first labour had been to kill the Lion of Nemea. Nemea is a fertile valley in the Peloponnesus (renowned for its red wine, actually). It was a sacred place in antiquity, with a famous temple to Zeus. But one of its residents was causing problems: a gigantic lion roamed the streets and the hills, devouring everyone it came across. Heracles tracked the animal down, but the lion had fur which was impervious to iron or bronze. Thus Heracles' arrows bounced off the animal, and his sword bent, and his club broke into pieces.
The only thing left was to wrestle the thing, so in a mighty contest Heracles fought the beast. The lion managed to nip off a finger from our hero, but eventually Heracles choked the life out of the Nemean Lion. Thus ended the First Labour.
Since nothing else would cut the lion's pelt, Heracles cleverly used its own claws to skin the animal, and fashioned the impervious pelt into his own protective clothing. Thus attired, he set off to accomplish his Second Labour: to kill the Lernaean Hydra.
Nearby lay the swamps of Lerna, home of the Hydra, an enormous dog-like monster with nine heads (one of which was immortal), and with breath that would kill on contact.
With the help of Athene Heracles located the monster's lair and the ensuing struggle was a standoff: as one head was sliced off, another appeared in its place. Then at Hydra's bidding, a giant crab emerged from the swamp and bit into Heracles' foot. Heracles promptly killed the animal then cut off the Hydra's immortal head, killing it as well. He then dipped his arrows in the Hydra's gall; the slightest scratch from one of these arrows would bring instant death to his enemies.
Scholars have expressed the opinion that astrologers later added the crab to the ancient myth in order to have the Twelve Labours of Heracles reflect the Twelve Signs of the Zodiac. While it is difficult to associate all of Heracles' labours with the zodiac, it is true that the crab figured in Heracles' Second Labour, and is in fact the Second Sign of the Zodiac.
In any case, apparently for following its mistress' command and sacrificing its life, the crab was awarded with a heavenly home."
Source: the Constellations