As everyone knows, organisms have DNA in their bodies, and this DNA is passed on to children. Every so often however, there is a mutation (a 'mistake' in the copying process). Most mutations are harmless and don't make any noticeable difference, while a few of them are bad, and a few of them are good. A good mutation can give that organism the edge over its competitors, which makes it more likely that that particularly will survive to reproduce and pass on the mutation (for example, the giraffe with a longer neck can reach food in trees which its competitors can't reach, so it's got more food to itself). This is natural selection, or as you might call it, 'survival of the fittest' (although I don't particularly like the term- any organism which lives long enough to reproduce is basically 'fit').
So no, evolution doesn't 'know' what an organism needs to survive, nor does it 'know' anything- it's just a process. Organisms gain their features at random, and those features that aid survival are more likely to be passed on to their children.
I know how some people like to talk about the intelligent design hypothesis, saying how some features are supposedly "too complex" to have evolved (usually without any quantitative measure of 'complexity'), so I'm going to pre-empt it. Intelligent design is bad science made up by people who don't have a clue about genetics or biology. For example, let's take the old creationist favourite, the eye. It's certainly tempting to think something so complex could only have been designed, but consider this: some eyesight is better than no eyesight. The first eyes to have evolved would have been incredibly primitive, barely letting you see how bright it was. But that's still better than not being able to see at all. Over time, some organisms evolved more and more complex eyes, allowing for directional vision, better focus, colour vision, etc.