How do we get complexity and perfect adaptation from random chance?

Evolution is not perfect. There are examples where we could design a better solution than the one arrived at by nature. The reason for this is that evolution has no "foresight."

Eye

The human eye is an amazing piece of biological engineering, yet it is not flawless. For example, the

A. The human eye as it ought to be, with a squid-like retinal orientation. B. The human eye as it really is, with nerves and vessels traversing the inside of the retina. (from G. C. Williams, Plan and purpose in nature, p. 10)

 

Male urogenital system

 

The gardener's problem seems easily solved: all he need do is go back around the tree to enable the hose to reach the rest of his garden. A much less sensible solution would be to lengthen the hose. this is exactly what happened in the evolution of the male urogenital system (see below). (from G. C. Williams, Plan and purpose in nature, p. 142)

 

The testis (on the right) draped over the ureter shows the present male configuration. It is the result of the gradual movement (in evolution and individual development) of the testicales from deep inside the body (the dotted linesd) to the scrotum. The testis on the left shows what might have been if evolution could anticipate future needs or correct past mistakes. (from G. C. Williams, Plan and purpose in nature, p. 144)

 

Recurrent laryngeal nerve

The recurrent laryngeal nerve is another example of "poor plumbing."