Heracles or Hercules was the illegitimate son of the God Zeus. When his wife Hera learnt about Heracles she resolved to get him killed. She hoped that the dreaded many headed Hydra would kill Heracles. The Hydra also known as Lernaean hydra was a many headed monster with a unique ability. If any head was cut, it was replaced by 2 heads. It also exhumed poisonous fumes which if breathed would kill an opponent. But the clue was that the Hydra had only one immortal head.
The Hydra lived in the swamps of Lerna. Beneath this swamp was a passage to the Underworld and the Hydra was a guard to that passage. Heracles was given the task of slaying the Hydra as part of the 10 labors of Hercules by Eurthystheus.
Heracles went to kill the Hydra with his mouth and nose covered with a cloth to ward of the fumes of the Hydra. He started by firing flaming arrows into the serpents lair. He also carried a golden sword which was gifted to him by the Goddess Athena who loved Heracles. Heracles confronted the Hydra in its lair with his sword, club and harvesting sickle. But in the battle whatever heads Heracles cut, two more grew in their place. After some time Heracles was in despair. Hera watching the fight was happy and assumed that the illegitimate son of Zeus would soon be killed.
The details of the struggle of Heracles and the Hydra are recounted in the Apollodorus. Realizing that he could not kill the Hydra Heracles called for help from his nephew Iolaus. His nephew came with an idea to scorch the cut head of the Hydra. Thus Heracles cut of each head and his nephew using a blazing firebrand to cauterize each head of the Hydra. The Hydra now began to lose. This disturbed Hera who sent a large crab to distract Heracles. He crushed the crab with his foot and he went on to cut the immortal head with the golden sword given by Athena.
Hera was upset that Hercules had killed the Hydra and placed it in the sky as the constellation Hydra. She then turned the crab into the constellation Cancer. The legend of the killing of Hydra by Heracles is one of the great romances of Greek mythology and one can savor it even now.