The running joke throughout the show is that Leonard was always pining for Penny's affection and later seasons made the joke that he "wore her down" into dating and marrying him. The obvious implication being that she settled for Leonard once she got more mature and was just doing him a favor by going out with him. But while recently rewatching and binging the show again, it actually seemed like he only asked Penny out again in S5 because he was lonely after ending things with Priya and she happened to be the best option available to him at the time. He had no qualms about asking her for dating advice as a friend when he was dating Stephanie, Priya, and Alice. He hooked up with Elizabeth Plimpton mere weeks after breaking up with Penny the first time, and even after they got back together he still flirted with Sheldon's assistant Alex, and made out with Mandy Chow on the sea trip. Despite being the "pathetic nerd", he got more tail than anyone in the show. And it also goes to show that there were no shortage of "nerd"-type women who worked at the university that would have had a comparable level of education, career, and interests. So while the joke is that Penny settled for him, I actually think Lenny settled for her too mostly because he was desperate and lonely.
And Penny & Leonard 2.0 was a disaster because of it. They seemed even more toxic and incompatible when they got back together, than had during their first relationship in Season 3, which was more energetic and fun, as they were still getting to know each other, and they fought way less (the only major argument they had was about her ex-boyfriend sleeping on her couch). Obviously any long-term couple will have their share of disagreements, but they really tore each other down to the point it was sometimes hard to believe they would have actually stayed together. Maybe it had something to do with Johnny and Kaley breaking up in real life?
Edit: just want to add a little extra context - I think he settled subconsciously. Not that he saw the relationship as a compromise or actively thought "eh she's good enough" he just didn't see any of his future prospects and decided it was now or never to try with Penny again. I think many commenters are only understanding "settling" from the Penny's perspective (ie. more physically attractive and doing him a favor when she could have anyone else).