President Barack Obama in NBC special talks legacy, how he 'worked really hard' for America

A tide of hope and change swept a young junior senator from Illinois into the White House eight years ago. But the bright idealism that Barack Obama represented dimmed into a stark reality: the most powerful job in the world required more than unwavering optimism.

Obama, who is winding down his second term before President-elect Donald Trump takes office on Jan. 20, spoke about the accomplishments and setbacks of his historic tenure in a wide-ranging interview with NBC News' Lester Holt.

The one-hour "Dateline NBC" special, "Barack Obama: The Reality of Hope," aired 10 p.m. ET Friday.

Holt was given rare access aboard Air Force One and to Obama ahead of the president's farewell speech in Chicago this week. The pair sat down to discuss Obama's legacy in health care and education, his disappointment in failing to get gun control legislation passed after the Sandy Hook shooting in 2012 and how he considers America stronger and more prosperous than when he took office.

"I never got weary," Obama said. "Every day I woke up and I worked really hard. And I worked really hard on the things that the American people cared about and on the things that are most important for our future."

A national dialogue about race was at the forefront in 2015 after the massacre of nine black worshipers by a white gunman in the name of racist ideology. His response as the country's first African-American president highlighted the good that can still spring from such tragedy.

"This was a moment when I think the entire country recognized — not just the evil that had been perpetrated — but also this amazing response on the part of these people in this church," Obama said.

His decision to sing "Amazing Grace" during an already emotional eulogy in Charleston was a freeing moment — born out of spontaneity, he said, and not political stagecraft.

Holt also spoke with Obama about the issues he's faced with in his final days, including the Russian government allegedly meddling in last year's election in order to help Trump win.

Obama declined to comment when asked about an unverified memo written by an ex-British spy that suggests the Russian government had compromising information on the president-elect. Obama told NBC News he ordered a report on the cyberattacks "because I felt it was important ... for everybody to understand exactly what happened in order to prevent it from happening again."

He said he hopes Congress and Trump will continue to investigate the claims even after he leaves office.

Key parts of Obama's legacy, including the Affordable Care Act and clean energy policies, face an uncertain future under a Trump administration. Obama said it will be up to successive generations to build upon the nation's "best impulses."

"We make progress, and then sometimes we take a step back ... before we start going forward again. But that's not a cause for despair," the president said. " That's a cause for hope."