And somehow that happens by chance?
(don't worry I read everything else you wrote)
Like... you accidentally get giraffes of the right size over time and then all of a sudden they are always the right size.
Not quote... but you are sort of going in the right direction.
Lets say you have a population of giraffes. Lets say there are a thousand of them.
If you measure them all, you will find that they will not all be the same hight.
In any environment there will be a perfect hight for a giraffe to be. If they are too tall, they will have a harder time supporting their heads. They will burn more energy pumping blood that high. They will use more energy maintaining the extra muscles.
But if they are too short, they will have a harder time feeding themselves.
So, there will be a balancing point or a sweet spot.
(Keep in mind that this perfect hight depends on the environment. If the trees are not that high, then the perfect hight will be lower, because giraffes that spend less energy growing that tall will be more successful, since they are more efficient.)
Anyway, back to the thousand giraffes.
You will have a bunch of giraffes that are not tall enough.
You will have a bunch of giraffes that are the perfect hight.
You will have a bunch of giraffes that are too tall.
Statistically speaking, the guys in the middle will have more offspring.
This implies that the next generation (again, statistically speaking), will have more members that fall into the sweet spot, since offspring get their genes from their parents.
This will continue generation after generation.
Now, chance DOES play a role.
Mutations are random.
Each generation, brand new mutations will be introduced. Since we are only looking at hight in this example, there are three possibilities.
1) A mutation can increase the hight of a giraffe.
2) A mutation can have no effect on the hight of a giraffe.
3) A mutation can decrease the hight of a giraffe.
This is random, in other words, how a mutation changes the hight of the giraffe born with that mutation is random.
Now, the perfect hight for a giraffe to be depends on the environment the giraffes are in.
You can have environment A, where a mutation is beneficial, and then you can have environment B, where the EXACT SAME mutation is deleterious.
Now, lets assume that the environment remains relatively static.
What will happen is that over generations, the giraffes will become increasingly adapted, until pretty much the entire population is the perfect hight for a giraffe to be.
Since they are all INSIDE the perfect region, any movement will move them OUT OF that region. Imagine that the perfect hight for a giraffe is 8m. Lets say that you have a giraffe that is exactly 8m high.
Now, it should be obvious that you cannot change the height of the giraffe, without moving it AWAY from 8m. In other words, any change in hight will make the giraffe LESS FIT.
So, once a population is very well adapted, all mutations will either have no effect, or they will be deleterious.
Now, imagine that the environment changes suddenly. This can happen for a variety of reasons. Lets say, climate change causes trees to be much lower.
Suddenly, all the giraffes that used to be perfect are not perfect anymore. Suddenly, mutations have the possibility of being beneficial again. Since it is possible again, and since they are random, beneficial mutations moving the giraffe population towards the new perfect hight can happen again.
Giraffes will adapt to the new environment. (Or they will go extinct.)
Now, imagine a population of giraffes. The one group stays where they are (group A), but a portion of them wander off into a different environment (group B).
What will happen is that the first group will evolve towards whatever is good in their environment, while the second group that migrated will evolve into whatever is good in their new environment.
Also, mutations keep happening, so any mutation in group A will be exclusive to group A, while any mutation in group B will be exclusive to group B. The result of this is that mutations will move the two groups AWAY FROM EACH OTHER.
If the groups remain apart long enough, their genes will no longer be compatible, and once this happen, they will continue moving away from each other.
Interestingly enough, both groups will still be giraffes. All ancestors of a population of giraffes will always be giraffes.
Another interesting thing about this process is that you won't see sudden changes. All changes are gradual. Each child will look pretty much the same as it's parent.
Does this answer your question?