The former president expressed concern about a future where facts are discarded and people only read and listen to things that reinforce their own views.
“One of the dangers of the internet is that people can have entirely different realities. They can be cocooned in information that reinforces their current biases.
“The question has to do with how do we harness this technology in a way that allows a multiplicity of voices, allows a diversity of views, but doesn’t lead to a Balkanisation of society and allows ways of finding common ground,” he said.
Mr Obama’s successor Donald Trump is a prolific user of Twitter, but Mr Obama did not mention him by name.
Mr Trump has been accused of overusing Twitter and following only a narrow range of users, though he maintains it allows him to connect directly with the American people.
Media captionBoxers or briefs? Prince Harry grills Barack Obama on his likes and dislikes
Mr Obama suggested face-to-face contact would help counteract extreme views.
“Social media is a really powerful tool for people of common interests to convene and get to know each other and connect.
“But then it’s important for them to get offline, meet in a pub, meet at a place of worship, meet in a neighbourhood and get to know each other.
“Because the truth is that on the internet, everything is simplified and when you meet people face-to-face it turns out they’re complicated.”
What were the pressures of being president?
“It’s hard, being in the public eye is unpleasant in a lot of ways. It is challenging in a lot of ways.
“Your loved ones are made vulnerable in ways that might not have been true 20 years ago or 30 years ago.
“So it is a sacrifice that I think everybody has to be at peace with when they decide to go into politics. But, ultimately, I think the rewards of bringing about positive change in this world make it worthwhile.”
Mr Obama pays tribute to the support of his family, especially his wife Michelle, describing how glad he is that she was “my partner throughout that whole process”.
And leaving office?
Mixed feelings given “all the work that was still undone”.
“Concerns about how the country moves forward but, you know, overall there was serenity there,” he added.
Mr Obama compared his time in office to being a relay runner.
“If you ran hard, you did your best and you were able to pass that baton successfully and the world was a little better then you had done your job.”
He cites Obamacare – ensuring more people can afford basic healthcare – as a major achievement.
“What an enormous blessing it is to say that 20 million Americans have health insurance that didn’t have it before.”
How does he see the future?
Without dismissing the problems faced by the world, he remains an optimist.
“If we take responsibility for being involved in our own fate, if we participate, if we engage, if we speak out, if we work in our communities, if we volunteer, then all the problems that we face are solvable despite all the terrible news that you see.
“If you had to choose a moment in human history in which you’d want to be born you’d choose today because the fact is that the world is healthier, wealthier, better educated and more tolerant, more sophisticated and less violent.”
What does Prince Harry have to say?
As well as editing, Prince Harry was himself interviewed on Today.
“I haven’t done that many interviews but it was quite fun, especially interviewing President Obama despite the fact he wanted to interview me.
“It’s been a big learning curve but also these are incredibly important topics we all need to think about and need to be discussed.”
The prince’s programme focused on issues such as the armed forces, mental health, youth crime and climate change.