I have friends who went to pretty good universities (world top 10), and I would love to apply too after my Masters although I am not sure how realistic this is, as I also had some personal problems during my undergraduate degree affecting my grades. However, I feel bad every time I think about it and realise that my university right now is not Oxbridge / Ivy League -although I too ultimately am interested in a career in academia.
One of my friends got into Oxbridge and I don't think he's more intelligent than me or particularly gifted at all to be honest, -but I just don't understand? - And: yes, I should know that it doesn't matter that much, and that I should not compare myself and not let this take over my thought processes. But I cannot seem to help it, it's on my mind a lot. And it's even keeping me from studying. - any advice?
Since nobody seems to answer this somewhat vague question, I will:
1) Your question is not related to Academia directly, it is simply a question about fighting negative emotions (perhaps, jealousy?) that stem from failure in some sort of a competition. You say your negative emotions interfere with your everyday functionality, so the standard advice is to go to personal psychological counseling.
2) The one bit that is related to academia is: "One of my friends got into Oxbridge and I don't think he's more intelligent than me or particularly gifted at all to be honest, -but I just don't understand?"
The answer to this is that academia is not an intelligence contest. It doesn't matter at all whether someone is intelligent or dumb. What matters is, for better or worse, whether you can deliver good research results.