Well, she did get more votes than Trump, but neither of them actually garnered a majority.
Clinton 47.2%
Trump 44.4%
Johnson 5%
The reason behind the court ruling is that there has been a push to get electors from both parties to go against their oaths to their states. It is a long shot movement that was hoping to garner votes from both Dem electors and Rep electors to install someone other than Trump (or Hillary for that matter).