At the end of The Sword in the Stone, it is true that Kay does receive the 'rough end' of the deal because he, being the son of a noble and a knight, and the Wart, comparatively nothing but a squire to Kay became the King of England when Kay thought himself more qualified and better for the position. However, throughout the Boy's childhood, Kay maintained the dominant position in their relationship. I think that it is only fair that in the end, justice is served and the Wart gets to rule over Kay. When the boys were young, Kay maintained a dominant position over the Wart, constantly reminding and humiliating him by saying that he 'was not a proper son' and 'Kay seemed to regard this as making him inferior in some way'. Because Kay constantly reminded the Wart that he 'was not a proper son' and said that he was inferior, upsetting the Wart, he learned to simply give in to Kay and always let him get his own way. After this constant torment and opportunities only available to Kay, I think that it is only deserving that, in the end, the Wart becomes more powerful and important than Kay, Sir Ector and the other people who had always 'ruled' him.
I think that the Wart was a better person to Kay and although he may not have been superior to Kay, he certainly had a better personality and was kinder than Kay. With Merlyn's 'education', the Wart learned not only how to lead well, but also to be a better person, and Merlyn taught him much about how to treat other people with respect and to relate better with them. When the Wart meets Robin Wood and Maid Marion, he learns through Marion that women are no different to men and should be treated equally. He is also taught the pointlessness of violence when he requests a joust between Sir Grummore and King Pellinore. Before the joust, Wart thinks that it is noble and brave to fight, but after seeing the Grummore-Pellinore joust, he thinks differently about it. He sees that there is nothing noble or brave about fighting to the death with a friend or fellow knight.
Although Kay did get the 'rough end' of the deal in the end, I think that he deserved it, after all the things he did to the Wart during their childhood. He held the dominant position for half of the boys' lives, and now the Wart holds the same position (in their relationship) for the later parts of their lives.