As I wrote previously, evolution doesn't have to be a process of random (genetic) change and natural selection. There's no reason that the process of evolution couldn't have the ability to plan which changes to make, conduct experiments, and retain the best results. After all, humans have the ability to design things, and we are merely matter, ourselves the product of evolution.
A recent scientific discovery sheds light on how this process might work. Studies "revealed that during evolution, the chromosomes are rearranged by breaking typically in specific locations, rather than in a random fashion, as had been widely thought." (See also here for more details)