The fact that evolution gave us imperfect memory isn't proof that imperfect memory is optimal.
I feel like you're fundamentally misunderstanding the process of natural selection. It's not about the engineering of optimal traits, it's about the perpetuation and dissemination of the best available traits. If a species has a widespread trait, it's because at some point in their history that trait made it easier for them to live long enough to reproduce, or was tied to a trait that did so.
Though as always, it's probably a good idea to emphasize that last bit. Evolution's definition of best is fairly specific, and only incidentally congruent with what we'd probably use the term for. If it doesn't effect reproduction and proliferation it basically doesn't matter; extended survival, health, happiness, improved capability, etc., is all secondary (if that) to that.
It's not so much best available as best available that has a sufficient impact on reproductive capability and genetic proliferation at a specific point in time. Which can be a pretty damn limited (and borderline random) subset of traits