Oh my goodness, this poor child. Growing up without a mum and right at an informative part of his childhood, he has lost his dad (albeit temporarily), and now he's about to be sent away by the grandmother who took him in. Not saying you are wrong to be thinking about this, but gosh, what a horrible time for this child.
You say that you didn't see much of him because you lived a long way away, and so if he is living with you, then he will have not only "lost" his dad, but also his home, his school, his friends, his activities. Everything.
I suspect a lot of the posturing and swearing and defiance will be him trying to protect himself, by trying to appear as thought he's not bothered about what's happened to his dad, and trying to appear "hard". But I'd bet that he's really scared and unsure of what the future holds for him.
There is an organisation that supports children of parents who are in prison, and understand the emotions and fears the children experience. It would be good for you - and him - to have someone to talk to. For the life of me, I can't remember their name, but I have the information at work, so if needed, I can add it on Monday.
How did he come to be placed with you? Did you offer, or were you approached and asked to care for him? If you were approached, then you should have ongoing support, whether that is from the Court (Cafcass?) or social services. I think what you are doing falls under a Kinship Care Arrangement, as you are a close relative, and I think you would have been assessed as to whether you are a suitable person to foster him, so you should have a named social worker that you can contact to talk things through with. You should also have been advised around obtaining Parental Responsibility so that if he needs medical attention, you are able to authorise this, and also advised around the financial aspects.
I think you need to contact your local Children's Services and ask for support from them, whether that is to help you keep your grandson with you, or whether it is to have him placed elsewhere.