As the story opens, the fishing village in which the characters live has been "sad" for three days, with cold, dark temperatures and constant rain. Because of a crab's life cycle, some species spend many months hiding in foliage above the waterline, waiting for rain. They live in burrows in the woods, trying to keep from drying out, and when the rain comes they leave their burrows and mate, going down to the waterline to lay their eggs. Pelayo's house must be in the middle of the crab's migration patterns, and since they are poor the crabs are able to get inside the house, posing a threat to their health.
On the third day of rain they had killed so many crabs inside the house that Pelayo had to cross his drenched courtyard and throw them into the sea, because the newborn child had a temperature all night and they thought it was due to the stench.
(Márquez, "A Very Old Man with Enormous Wings," salvoblue.homestead.com)
Too many dead crabs means decomposition and rot, which Pelayo blames on the ill-health of the baby. He can't simply kill and cook the crabs, because there are too many; instead, he takes them down to the ocean and throws them in. Meanwhile, the crabs are taking advantage of the rainy season to mate and lay eggs, and this continues until the rains stop. Pelayo's trips to the ocean are what spur his discovery of the angel, and later he is able to buy a better house for his family, so they can be safe from the crab migration.