From “Why we love” by Helen Fisher:
Why do lovers continue to hope, even when the dice of life come up relentlessly against them? Most still hope the relationship will spring back to life—even years after it has ended bitterly. Hope is another predominant trait of romantic love.
I think this tendency to hope became implanted in the human brain eons ago so our ancient forebears would doggedly pursue potential mates until the last flicker of possibility had expired.