Why do animals kill their young?

Source: nationalgeographic.com
It happens both in the wild and in captivity: animals kill their young, and sometimes even eat them. Both males and females can exhibit such behaviour. Is this the (often cruel) hand of nature, or is it pathological? Biologists have yet to come to a conclusion.
Lions are a familiar example, as lion males are known to kill cubs. A pride of lions consists of one or two males, a number of females, and the cubs of these males. When another male takes over the pride, he immediately kills the young — although the females try to prevent it. The females soon become fertile, and able to mate. The new male lion then has his own young (his own DNA) to care for, and does not have to exert himself caring for young with strange DNA. Common to nearly all primates, including chimpanzees and gorillas, this behaviour is not seen in bonobos; possibly this is because all animals in a bonobo group mate with one another, making it more difficult to know which individual is the father of particular young. Bonobo females are also dominant, which makes it riskier for a male to hurt a young ape.

That mothers kill their young, and then eat them, is altogether different. Biologists suspect that this behaviour is related to a problem (a congenital defect) or disease in the young animal. The mother kills the young in order to keep from wasting energy and food. Subsequently she eats the animal, to keep the nest clean — a rotting carcass would attract predators — and to make good use of the young as a source of food. Food scarcity can also be a reason for a mother to kill her young, as mammals require a great deal of energy (from good quality food) to be able to feed their young.

In zoos, care is taken to prevent animals from killing their young: with careful administration of breeding programmes, wise composition of animal groups, and appropriate provision of birthing boxes. The young may be taken away from the mother quickly if there are indications that she might kill it. The young may be hand-reared and later reintroduced to others of its species.