There's different ways to look at it. Evolution doesn't plan, and the development of this or that compound is driven by random mutation- but it reliably exhibits all kinds of emergent behaviors, like evolutionary arms races, convergent evolution, and so forth. Like many other systems with feedback, given a set of constraints it reliably trends towards a local optima.