Hillary was too stupid to realize that the election is determined by the electoral college, not the popular vote. Trump, being intelligent, focussed his campaigning in the important swing states. Hillary didn't.
If the election were decided by the popular vote, Trump would have spent a lot more time in New York and California convincing the people there to vote for him. It's better to be smart than stupid, that's why Trump wins and Hillary keeps losing.