Well, it appears to be for sexual selection. The standard story about why giraffes have evolved their incredibly long necks states that this trait has helped them in reaching to higher leaves. This story, however, is probably wrong. Observations of giraffes have shown that over 50 percent of the time, they feed with their necks horizontal and that during the food-scarce dry season, they feed in low bushes rather than in tall trees. The giraffes are obviously capable of feeding on higher leaves than other animals but this advantage doesn't seem to be sufficiently great to justify the costs of having such a long neck.
The giraffes' head is about 3 meters above the heart which makes it very difficult for the heart to pump blood to the brain. The giraffe has the highest blood pressure of all mammals and its heart weighs up to 10 kg. The largest giraffe on record was almost 6 meters tall and weighed about 2 tons. In spite of their size, the giraffe can run very fast, up to 60 km/h (aprox. 35 mph). Their heart seems to cope with such effort. Their front legs are 10 percent longer than the back legs which might also help them run.
Another reason why it is unlikely that the giraffe's neck has evolved due to feeding habits is that its closest relatives, although big, had short necks. The discovered fossils reveal large animals with long legs rather than long necks. The largest giraffe relative discovered insofar had legs almost twice as long than those of modern giraffes but a short neck. Other giraffe relatives have had impressive horns - while the giraffes have only two small horns. The giraffe evolved around 1 million year ago in the African savannah at the time when our ancestor Homo Erectus had already spread from Africa throughout Asia. The giraffe ancestor was significantly smaller in size and had a shorter neck than today's giraffes. So, what favored the growth of that incredible neck in a relatively short time?
One proposal is that the neck helped the giraffe spot predators from the distance, but most biologists reject this explanation as being much too ad hoc. Instead, the most widely accepted hypothesis is that the neck evolved under the pressure of sexual selection. Thus, the giraffe's neck is similar to the peacock's tail or to the moose's horns.
This explanation is in no way obvious, especially because the female giraffes also have long necks, while sexual selection usually favors such "wild" traits only in males. Nonetheless, observations of giraffes' behavior seem to support this view.
The first clue is quite direct: male giraffes, unlike female giraffes, use their necks to fight each other. Moreover, before an actual fight, they point their noses upwards as if they are trying to create the impression that their necks are higher. Researchers have discovered that this is indeed a sign of domination as some males run away from a dominant bull that does such a sign.
"An average male giraffe's neck weighs 90.72 kg. and can stretch 1.83 meters long. Giraffes fight over females by swinging their necks and heads like a medieval ball and chain. The longer and heavier the neck, the more momentum behind the often bone-shattering head slams," Kathy Wollard remarked.
A study in the 1980s by Pratt and Anderson had shown that the main criterion that determines the dominance among bulls is neck size. They classified the giraffes in three classes, A, B, C according to neck size and horns lengths and discovered that neck length is what counted. "The larger-necked A bulls were consistently dominant over B and C bulls, and they courted females significantly more often than B or C did. Ranking also appeared to be important in female mate choice: females allowed themselves to be urine tested (a test of their sexual receptiveness) by A bulls more often than B bulls, and they refused to be urine tested by C bulls in two-thirds of all encounters," wrote Robert Simmons and Lue Scheepers who first argued in favor of the sexual selection theory in the 1990s.
But why do female giraffes also have long necks? Simmons and Scheepers argued that the neck, unlike the tails or the horns, is a trait much too heavily integrated in the organism to be controlled only by a small number of genes. Therefore, the females necessarily inherit the same "neck genes" as the males.
There are however differences between males and females - exactly as one would expect from the theory of sexual selection. Female giraffes do have smaller necks than the males because their necks stop growing in their "adolescence", when they are around 6 years old. This probably happens because females have a gene that silences the neck-growing genes. The males' necks on the other hand grow constantly throughout their lives (giraffes live about 20 years). The largest males are about 53 percent heavier than the largest females.
The fact that the neck is a hindrance and has a large survival cost has been demonstrated by other studies, conducted since the late 1960s, which have shown that male giraffes were about twice as likely as females to be killed by a predator - mostly lions. This kind of difference, again, is a hallmark of sexual selection.
Finally, there is another interesting fact that can explain the long necks of female giraffes. The male giraffes are among the most homosexual mammals. Bruce Bagemihl has discovered that in some areas, 94% of mounting incidents were between two males. Males don't just fight with their necks - in one in 20 cases they engage in affectionate behavior. On the other hand, female giraffes engage in homosexual behavior only in one percent of the time. It thus seems that female giraffes have sexually selected males with longer and longer necks, but the males themselves find long necks sexy. So, in order to still get males, females also had to grow long necks.