There have been many theories explaining evolution. Two of the most well known of these are the Lamarckian theory, which was mostly believed before the Darwinian theory, which is the theory which is believed to have the highest probability of it being the case.
In Lamarck's theory of evolution, he stated that an organism was able to pass on required traits to their offspring. This theory is commonly shown through the giraffe's evolution to having longer legs and a longer neck. According to Lamarck's theory, during a bad season when all the vegetation in lower areas (easily reachable by the giraffe with the shorter neck and legs) had gone, the giraffes were forced to stretch their necks, to reach for food on a higher level. These giraffes would then have longer necks and would pass this trait of having a longer neck to their offspring. Lamarck's theory then states that over time, each generation will pass on their traits of having a longer neck than the previous generation, accounting for the evolution of the giraffe from being an animal with a shorter neck and legs, to one seen today with its long neck and legs.
Darwin's theory relied on a process of natural selection. In his theory, at the start there would have been many giraffes of varying heights, which would be so due to the variations in organisms through the process of sexual reproduction. Darwin stated that all life competes in a struggle to exist. Therefore, during a dry season when there is not as much nutrition available on lower levels for the shorter giraffes, the giraffe's that are more likely to survive are the ones with the longer necks and legs. The giraffes with the shorter necks and legs would die, disabling them to pass on their genes for the shorter legs and necks, resulting in a new generation of longer necked and legged giraffes.
These theories can also be shown using other animals such as the horse. The ancestors of horse were once much smaller than the modern day horse. They had four toes on the front legs and three on the back. These toes were padded so they allowed the horse to easily move through wet ground. As the horse moved out of the forest and swamp areas to the plains its head, neck and legs became longer, allowing faster movement and it adjusted to standing on only one toe.
Lamarck would have said that this change was from the horse changing its traits to match its environment. The horse would have had to struggle to run faster to escape from predators when out in the open, and therefore developed a stronger, body to cope with the need for speed.
Darwin's theory would of course differ to this, saying that the horses that survived were the ones, which were able to run faster. These would have been the horses with the longer legs, and so the genes for the horses with the longer legs would be passed on to the next generations.
These theories have been widely believed to be the explanation for the varying species of animals on the earth. It is well known now that the Lamarckian theory is not possible, and therefore the Darwinian theory is the explanation that is believed to be the means of evolution. This, however has not yet been proven, however the probability is very great.