Evolution does not necessarily move towards optimal systems, by any definition. It may find local optima, but the process has no guarantees it's moving towards a global optimum.
EDIT: Here.... let me google up an example. https://en.wikipedia.org/wiki/Great_Oxygenation_Event