I'm a history professor and wrote my third book, Presidents' Body Counts': The Twelve Worst and Four Best American Presidents Based on How Many Lived or Died Because of Their Actions.
Too often, rankings of presidents become popularity contests based on ideology, or who fits closest to their own belief system. Thus we have absurd rankings like a poll by the Wall Street Journal who ranked GW Bush the 6th best president of all time.
I rank presidents based on humanitarian standards. Who caused the most deaths? If the deaths were by mass murder, that obviously counts far more than incompetence. Thus the worst president in US history was Nixon, who ordered the carpet bombing of neutral Cambodia, outright genocide that killed 600,000. Reagan was the second worst, killing 325,000 in Central America by terrorism in Nicaragua and El Salvador and support for outright genocide in Guatemala.
The best president in US history was Lincoln. Defeating the Confederacy ended slavery, and slaves had an infant mortality twice that of free people. The Confederacy also planned wars vs Cuba, Dominican Republic, and Mexico. Lincoln saved hundreds of thousands.
But since the question is about the 20th century, the best US president was Jimmy Carter. The Camp David Peace Accords prevented perhaps as many as 100,000 future deaths in wars. Carter's human rights policy saved at least 50,000 dissidents and aided democracy in at least 25 nations, and ended the Cold War sooner. (Reagan prolonged the Cold War by his rigid anti Communism.)
Raphael's answer of FDR is partly true. He accomplished much good. But FDR also ignored the Holocaust, targeted German and Japanese civilians, and imprisoned Japanese-Americans for racist reasons.
John's answer has some problems. TR was a warmonger, invading nations in Latin America. He broke Panama away from Colombia. The building of the canal killed thousands of Panamanian Black workers, who were denied the disease free quarters of US white workers by US segregation. TR's progressivism, like other progressives of the time, was based on racism and class warfare beliefs that both nonwhites and poor people whether white or not were incapable of running their own lives or knowing what was best for themselves. Thus he hated socialists and populists, though both parties did much good for the US, giving us direct election of senators, referendums, the Pledge of Allegiance, and social security (much later.)