Former President Barack Obama was the public's choice for the greatest US president in their lifetime, according to a new Pew Research Center poll.