Our optimism bias has likely been favored by natural selection, as it is often associated with greater success due to its links with more risk-taking or venturing, creativity, persistence, and resilience.
However, the extent of optimism has likely been kept in balance because too much optimism would be an unsuccessful trait for survival due to excessive risk-taking and insufficient caution.
The optimism bias operates mainly when we evaluate the likelihood of good or bad things happening to ourselves.
From “Finding Purpose In A Godless World”. Ralph Lewis. 2018.