1. First, throw out those 'value' terms like bad and good. They confuse the issue, because they come preloaded with a bunch of asuumptions we've attached to them.
2. Then, discard any idea that any organism "realizes" that it needs something to survive better. They don't. It's not necessary.
3. And finally, chuck out the idea that evolution is random. It isn't - it's always driven in a certain direction by the selective forces that act on the organism (even if that direction is subject to change without warning).
The basic idea is this: Things come in a range of varieties, right? Big. little, different colors, different shapes, whatever. Those things that have offspring pass on their genes to the next generation, and those that have more offspring increase the relative amount of their genes in the population. OK, now if some variety of a particular thing has an advantage over the others (maybe it catches more food; maybe the females find it sexier; maybe it breeds for a longer period or its offspring survive to adulthood better, etc., etc.), then after a while the population of that thing will look mostly like that variety. Now introduce some change - perhaps a mutation that (in a freak one-in-a-billion-or-so chance) turns out to be helpful; or perhaps a change in the environment that takes away the advantage from the first variety and gives it to a different variety of that thing. Anyway, now this different variety has the edge, and starts producing relatively more and more offspring. After a while, the population will now mostly be made up of this variety, and so it will have changed (evolved). Most of these changes aren't enough to make a "new" species, they just modify the original species over time as the world varies.
But, suppose that a part of the original population gets isolated somehow - part of the forest dies out and traps them in a relatively small area, where they no longer have any contact with the rest of the species. Or some individuals get blown out to sea by a storm and land on an island where they can survive with little or no competition. Or whatever; the point is that they continue to change over time in response to the pressures of life where they are, and the original population does the same. If the selective pressures on each are different; if the available varieties within each population are different; if the populations diverge over time, then at some point, they may be recognized as different species. Selection drives evolution (=change over time) and evolution may result in speciation if certain conditions are met (primarily reproductive isolation).
Note that it may look like evolution is 'directed', but that's misleading - we don't see the failures; we only see the end result and then say "of course it had to come out that way!" This is particularly a problem with the fossil record, where only a very, very, teeny-tiny, unbelievably small number of the things alive at any given time happen to be preserved for us to find later (probably a bit here and a piece there, at that). If we have only a small number of examples, what do they tell us about the species? Suppose that some time down the road, alien researchers find some human remains from two sites - one has the mortal remains of Yao Ming and Grace Jones, the other fragmentary remains of a man who stood 5'6" and a woman who was about 5'1". If those were the best examples of humans they had, they would probably define contemporary humans as two species: Homo altitudina and Homo minima (or whatever equivalent terms they used in their weird alien language, of course...), and make up lots of interesting stories about the life cycles of these two different species.
Well, this essay has turned out longer than I expected, so I'll drop it here. If you want some nice, interesting story-telling on evolution, I suggest you dip into SJ Gould's stuff. It's a good place to start. Just remember that scientists are very much like religiousists in that nobody agrees on all the details and sometimes disagreements get a bit noisy. Luckily, scientists have yet to start world-wide holy wars over their disagreements, although there are occasional fist-fights and lots of name-calling. I think the difference is mainly that scientists are generally beer (or whiskey) drinkers, while religiousists tend to suck down a lot of wine. Never trust a heavy wine drinker, is my motto.