While some scientists have speculated that giraffes are the shape they are so they can browse from the treetops the truth is much sadder. You see, giraffes are very prone to depression, and it is not uncommon for them to attempt suicide. When they do so it is always by hanging, and at first this worked quite well and most suicide attempts were successful, but a few survived and continue to live and have children, and over the generations those with longer legs and longer necks have proven more likely to survive their suicide attempts and so the giraffe has evolved into its current form which is virtually un-hangable.
These days giraffes still attempt suicide, but it is almost always unsuccessful; their failure to end their own life even after multiple attempts has done nothing to improve their self-esteem and depression is more of a problem than ever.