Cantor had much deeper pockets for campaign spending. Since he lost, it comes down to a few factors, one of which is that he and his staff underestimated David Brat as a challenger especially on issues like immigration. Having access to the kind of funds Cantor can draw means that he should have been on top of the polls and more aware of the public response to his challenger.
Many say that he neglected his home base and just assumed he would get the vote. When the supporters didn't turn out at the polls he ended up losing by a very small margin. There is some talk that he was even in Washington DC during the election day and not in his home state of Virginia. I believe he underestimated David Brat and also overestimated his supporters.
Yes, Cantor underestimated David Brat as competition, because a sitting majority leader has never lost a primary election for reelection. Cantor just assumes that people agree with his Rhino agenda. But we don't. We want to be a free people, and we want laws enforced. Cantor thought the Republican machine could override people's opinions. He lost.
What Cantor underestimated was how angry he made the people, especially the people in his district. The problem with it is the fact that people remember that he was heavily involved in the government shut down and they aren't happy about it. He hurt America and now he's paid the price. He shouldn't worry however, he's got that sweet pension that they give representatives.