As an individual who went to a state school for GCSE but a grammar school for A Level, it does give you an advantage but I wouldn't say it's unfair.
For starters, you're pushed to a much higher ability in classes and you're surrounded by like minded students who also produce work to a high standard. Everyone in your set is aiming for a top grade. For me, this definitely meant I was more productive, there's a sense of competition as everyone wants to be getting high marks. In my comprehensive school, we'd spend ages going over "how to achieve a c in gcse history" and I just switched off. This is definitely an advantage, you're not dragged down by lower ability students who need more attention to achieve, meaning the teacher can tailor the lesson to higher grade stuff.
Secondly, you're also encouraged to achieve your dreams way more. In comprehensive, our teachers would often say certain dreams were too ambitious however since getting into a grammar they're much more supportive and this to me, pushed me even further. At comprehensive it was almost as if I should just be content with whatever.
In short, if I stayed in my comp and did not move for sixth form then I don't think I would be on track for decent grades. Of course this is unique to me personally, and I know there are many comp's out there which are high achieving however my school was certainly not one of them. And, also, grades are dependant on a persons own ability, the school can only do so much preparation.