When Ban escapes from prison he explains that he allowed himself to be imprisoned because back then he craved pain. This gave him, in a twisted way, pleasure but he grew tired of it. When he heard Meliodas was nearby, he escaped because following him would be more fun than being locked in a cell with bars through his limbs barely being fed.
It takes visiting the after life, having his team fight the resurrected Helbram, and fighting with Captain to decide to go out on his own to resurrect her. He is obviously more than willing to take any opportunity to bring her back (even betraying his team) if he observes an opportunity. This seems to indicate that he gave up for a while and did not pursue that goal because he did not know how to bring her back. He didn't seem to have a known way to bring her back but since going off on his own, he has started to search desperately. I would expect he did the same before going to prison.
Keep in mind that, for an immortal man and long-lived fairies, 5 years isn't a very long time (even though it took much less time to fall for each other). This was almost like taking a (pleasant?) vacation when he had no clear time constraint on his project despite it's obvious importance to him. I would assume their was some guilty and self-contempt involved too.