So it is a misconception to view natural selection as a process that perfects organisms. At the opposite extreme, natural selection is sometimes interpreted as a random process. This is also a misconception. The genetic variation that occurs in a population because of mutation is random — but selection acts on that variation in a very non-random way: genetic variants that aid survival and reproduction are much more likely to become common than variants that don’t. Natural selection is not random!
Learn more about random mutation or the process of natural selection.