Some people just have a more logical brain and just get maths. I am ranked in the top 1/3 of my class and I put in very little effort whereas there are some who work their butts off and are ranked towards the bottom.
Everyone has their own strengths and weaknesses, they may do amazing at maths but then struggle at something else, for example I put the most effort into EngLang than any other subject yet I am ranked 2nd last in my class.
But someone who works hard and isn't naturally talented will usually do better than someone who is naturally talented but doesn't feed their talent by working hard. Hard work ALWAYS beats out talent in the long run, no matter how naturally talented a person is if they don't work hard they will not do as well as a person who does work hard.