15 million years ago, antelope-like animals roamed Africa. There was nothing special except for some of them had longer necks. These animals were the species, canthumeryx
In the African Savannah, there are trees that are very high. Because of genetic variation in the population, there were some animals with longer necks and some with shorter necks. Those with mutations in their genes that caused them to have longer necks, had the advantage of being able to eat the leaves at the top of the trees that no one else could.
Because of increased population of giraffes but a stagnant amount of food, there were more giraffes that the savannah could feed. Over time, the longer necked animals had more to eat thus increasing their chances of survival. The longer necked animals matured to breeding age while shorter necked giraffes died earlier because of the lack of access to food.
The higher vegetation and food scarcity became a selective pressure for ancient primitive giraffes. Shorter giraffes died due to lack of access to vegetation and never reproduced. The short neck gene never got to pass on to the next generation while long neck genes were inherited by the next generation of long neck giraffe spawn.
throughout the evolution, more and more of the offspring inherit the advantageous long neck trait and short neck giraffes slowly become extinct due to the lack of reproduction.
In present day, these animals have evolved to have 6ft long necks that fit perfectly to their savannah environment. These animals had mutated to have te gene variation best fit for this environment and those who couldn't adapt and didn't mutate, slowly died off.