There have been five Presidents who took office without winning the popular vote.
The first was John Quincy Adams, a second-generation President. His presidency ended with his rematch with Andrew Jackson. Afterwards he had a distinguished career as Congressman and abolitionist.
Rutherford B. Hayes didn't even with the Electoral College outright. Rather, Congress decided the winner in his race with Samuel Tilden. Not too surprisingly his reputation never recovered.
Benjamin Harrison did at least with the Electoral College, but like Hayes he was mostly forgotten after his single term.
More recent are the cases of George W. Bush and Donald Trump. And they both present a change from their predecessors in that they lost the popular vote the first time and came back to win it the next time. But even between them their stories are more different than alike.
Bush was reelected and improved his share of voters for a very straightforward reason: 9/11 made him a War President. His big war was neither particularly just nor particularly well-prosecuted, but most Americans weren't going to criticize him. Not in 2004 at least.
Trump's story takes a more circuitous path. He was impeached twice and then spent four years out of office before winning a nonconsecutive second term. What drives the story here is that Joe Biden successfully campaigned on a return to decency, for which you can substitute "establishment norms." But then during his Presidency and the campaign of Kamala Harris, voters got a look at what the 2020s political establishment was. Not too surprisingly they ran screaming in the opposite direction.