He is Ender's friend because everything he does, he does in the name of helping Ender. And, he does it at the risk of his own job--he repeatedly angers Major Anderson, breaking rules and code to help Ender. In the end, he even faces charges for his actions in helping Ender.