Many observers of giraffes have noted their extraordinarily long necks, leading to a great deal of speculation about why giraffes have long necks. There are a number of theories, but the most probable explanation is that giraffes with longer necks are more successful in fights, and giraffes which win fights are able to breed. The famous neck of the giraffe has apparently evolved out of a desire to win battles, and centuries of natural selection for longer, thicker necks has led to the modern giraffe.
The long neck of the giraffe is supported with extremely strong anchoring muscles which help the animal keep its head upright. As a result of the evolution of long necks, giraffes have had to make several adaptations to survive, including the development of a very powerful circulatory system which pushes blood from the heart to the brain. Considering the physical stress created by having such a long neck, there's no clear biological advantage for giraffes, as demonstrated by the general lack of long-necked animals in the world.
Some people claim that giraffes have long necks so that they can reach high foliage on trees and shrubs, under the argument that being able to reach high foliage would allow giraffes to access food during drought periods when leaves are scarce. Researchers who studied giraffe feeding patterns found that, in fact, giraffes tend to browse low, lowering their heads to eat. In the wet seasons, when there is a great deal of foliage overhead, giraffes may browse on high leaves.
Other people have suggested that giraffes developed their long necks so that they can clearly see approaching predators. Biologists have largely dismissed this theory, arguing that if being able to see across great distances was such an advantage, more animals would have long legs and necks. While the fact that giraffes have long necks has certainly made it easier to spot predators, it is unlikely that giraffes evolved long necks specifically for this purpose.
Giraffes and many of their relatives fight by essentially beating each other with their necks and heads, in a process known as necking. Male giraffes use their necks like deadly weapons, whipping their necks around and clubbing their opponents with their heavy skulls. The longer and thicker the neck, the more of a punch it packs, so it seems that giraffes have long necks so that they can fight more effectively.
For those who are interested in another factoid about these African mammals, in addition to having lengthy necks, giraffes also have very long tongues. The animals use their tongues to reach around the thorns of acacia trees to reach the leaves without hurting their muzzles.