I'm really interested in your view that the law is clear. It's incredibly complicated!
The Home Office don't give "advice," they make a decision which is appealable.
The deportation decision was made on the strength of the 2 year sentence for false imprisonment. At this stage he had not been convicted of rape and nobody knew that he would be in future.
The law is that there is a presumption in favour of deporting a foreign criminal who has received a sentence of more than 1 and less than 4 years, unless certain exceptions apply. One of them is that the person is "socially and culturally integrated" AND that there would be "very significant obstacles to their integration in the country to which they would be deported."
The HO in this case appear to have argued that the appellant wasn't socially and culturally integrated even though he had been here since infancy. You might think that's a pretty weak argument and that they might have done better to focus on the material realities of how he would integrate to Nigeria.
Very significant obstacles to integration are clearly in play when it is proposed to deport someone to a country they have never even visited.
The HO didn't turn up to cross examine him about his attitudes to women, the extent of his rehabilitation or whether he had any extended family ties in Nigeria, or even whether his UK based family would send financial support, all of which would be relevant to the "very significant obstacles". He said that he was rehabilitated and more importantly, Probation supported that and assessed him as being at a low risk of reoffending (plainly this turned out to be wrong with the benefit of hindsight).
It may be that the judge would have come to a different conclusion if the evidence before him had been that the appellant was at high risk of serious sexual reoffending and / or there had been evidence in cross-examination about how he would practically live in Nigeria. But the judge can only make the decision on the evidence that is available to him.