For a long time Democrats did well by bribing poor voters with things, (carrots), free medical care, free food, free money; free free and amnesty too. Lots of people want free and gladly voted for anyone who promised to give them stuff, even if they know it's being taken from other people and no one knows how we're ever going to pay for it.
Oh but now Democrats are the party of hate, and they lost votes from all the people they demonized which in this case was just enough to get Trump elected. They did it by alienating lots of people who disliked Trump but hated being told they are RACISTS because they thought our borders should be secure and believed someone who was here illegally was an illegal immigrant. They disliked being called a RACIST because they didn't agree with everything Obama did, and certainly they were if they disliked Obamacare, or thought people like Jessie Jackson were charlatans. Perhaps next time Democrats refer to half of the United States as a "basket of deplorable", they should do a little math first.