I am a historian!
The worst presidents in history, my own ranking:
1. Andrew Johnson is the clear winner for utterly failing Reconstruction. He wouldn't even have to be a radical republican; had he just held Lincoln's moderate views, or a measure of Lincoln's political skill, Reconstruction likely would have gone much more smoothly.
2. James Buchanan is second worst, for failing in any meaningful way to prevent the Civil War or, barring that, to prepare his successor to fight for the Union. In addition to this, he had many of the usual distasteful artifacts of the era. He was also fairly corrupt and clearly lacked vision, vetoing both the Morrill Act and the Homestead Act. The only reason he is not the worst is because, as noted, secession was a big thing that had been stewing for years.
3. Richard Nixon is third, not just for the obvious things, or his much-overrated foreign policy. He both helped to create the imperial presidency and then, in basically getting away with it (excepting his resignation) fatally undermined the notion of the rule of law and accountability. The misdeeds of the political class since 1980 can be largely attributed to this; people torture and steal and start wars with no realistic concern of punishment.