So far as anyone can tell, genes mutate more or less at random. Reproduction is not an absolutely reliable process, and genetic material can be altered by all kinds of causes. So genes mutate, and this means changes in the pool of traits that can be inherited.
Mutations can accumulate over long periods of time.
Here we will call any hereditary trait an adaptation when we are considering whether it enhances or detracts from an organism's fitness. Evolutionary biologists infer common ancestry from the presence of arbitrary similarities in inheritable traits among organisms. They do not infer common ancestry from nonarbitrary similarities. It is when organisms are similar in regard to these imperfect traits that they are said to exhibit arbitrary similarities, which are evidence of common ancestry. Given the two principle parts of evolutionary biology, plus natural selection, we would expect to see less than perfect adaptations, i.e., we would expect the fitness-enhancing traits pervasive in a population often to be less than perfect.