Grover Cleveland was the sixth president to serve since Abraham Lincoln won the civil war and was shot to death in 1865. At this point, the nation was a little over twenty years removed from the end of the war, had been through the reconstruction period and was well into the gilded age. The reason he got elected was as much about his republican opponents failed strategy as it was about his own grasp of politics.
Since the north had won the civil war, the republicans who were predominately from the northeast and midwest had made blaming the democrats for the war an integral part of their campaign strategy.
The strategy made a lot of sense at first, southern politicians were mostly democrats and many northern democrats harbored some sense of loyalty or at least sympathy to the confederacy in the 1860's. It continued to work well when after the war, southern politicians who had served in the confederate government once again became the congressmen and senators of the reunited country.
The problem was that it worked so well to stir up the republican base that some politicians never stopped using it as a way to scare the voters into electing them. In many ways, even twenty years on in the 1880's, the civil war was like the 9-11 of its day. Just like republicans of today continue to brand Barack Obama (the man that killed Bin-Laden and scores of other Al-Qaeda terrorists) and all other democrats as 'weak on terrorism', the republicans of the 1880's continued to imply that voters who elected democrats were somehow disloyal to their country.
Voters got tired of this strategy for several understandable reasons. The foreign born population had exploded since the 1860's due to war and famine in Europe and that constituency was much less swayed by anger at the South than the older native born population that had actually lived through the civil war. In addition, twenty years after the civil war, a fair amount of the war population had passed on and the younger generation were either too young to remember the war or were not even born when it took place.
The Republicans realized that immigrants were much less likely to vote for them and sought to tar them as also being disloyal to the United States due to their 'Romanism'. The anti-Catholic and foreigner rhetoric was ironic, coming from the party of emancipation of slaves. Eventually, voters tired of this fear driven agenda and the republican party lost influence even in its stronghold of the northeast.