Whales were once thought to have lived on land many millions of years ago. This is why some say that whales beach themselves because they are sick and know they are going to die. So, they swim back into the shore to die from where they once originated, before they adapted to the water. Like a strange and imminent calling. However, whales most likely end up beached and on the shore not because of some strange and imminent calling, but rather they might be in the shallower waters when high tide comes, then when low tide comes, they can't swim out to sea fast enough, so they are trapped in too shallow water for them to swim in and they ended up stranded on the sand, therefore they get beached. And just in case you're wondering, whales never attempt suicide. As weird as it may sound, whales don't have the brains or a reason to get "depressed."
There is also the possibility that they are injured and in danger, so they swim in to evade a predator. They are definitely mysterious creatures.
It is still not fully understood why whales beach themselves. There are many theories and proposed suggestions as to why they would do such a thing, but nothing thus far has been proven.
One major theory that has surfaced in recent years is submarine sonar equipment. Supposedly, whales and other marine life are driven crazy by the pulses put out by sonar, and in whales, it causes a condition alot like 'the bends'. The whales panic and flee. Often times they will be so badly affected by the pulse that they don't realize they are drawing in close to shore, and they'll just crash right into the beach.
Other reasons may include sickness. They may lose their sense of orientation and wind up on the beach.
They may be trying to escape a predator or predators. While there is no known creature in the oceans large enough or threatening enough to send dozens of whales fleeing, many larger whales are prey for Orcas (Killer Whales) and sometimes larger whales will beach themselves while attempting to flee pods of Orcas.
There are many possible explanations to this phenomena, and these are only a few.
Several hypotheses have been put forth to explain these strandings which likely have multiple causes. The whales may be sick or hurt; illness or parasites may affect their sense of direction. It is believed that whales use magnetic fields and underwater topography to orient themselves. For this reason, a magnetic field deviation or an odd coastline formation could cause confusion.
It is not an uncommon occurrence for beached whales that have been returned to deeper water to later strand on the same beach from which they were freed.
Their reference points may wrongly lead them to believe that deeper water lies in the direction of the beach. Live strandings often repeatedly occur in the same area, in zones with specific characteristics.
Pelagic species of whales that are more at home in deep, mid-ocean waters may get caught off guard by the falling tide in shallow estuaries. In the case of mass stranding, whales may simply be following a confused leader, or they may be swimming to the aid of an already stranded whale that is sending off a distress call.
Essentially, these strandings remain somewhat mysterious.
A live beached whale may die of disease or injury. In these cases, the disease or injury may also be the cause of the whale's stranding.
If the whale is neither sick nor hurt, but is not able to get back into deep enough water, with the rising tide for example, it will generally die of complications related to being out of water.
At sea, water supports the whale's body. On land, air does not offer this support. The whale's body weighs it down and it may "suffocate" under its own weight; its respiratory muscles are incapable of sufficiently dilating its rib cage to ensure adequate pulmonary ventilation. Also, on the portion of the animal's body that is in contact with the ground, blood circulation is blocked by the animal's weight, causing tissues to die. Even if the animal is returned to the water, these dead tissues will produce toxins leading to generalized infection.