A couple of reasons that James Baldwin cast the narrator as an algebra teacher is because he is comparing an object approach to managing the suffering of life and a subjective approach. The narrator takes an objective approach, which has its pitfalls, but nonetheless allows him to hold his head up with dignity in society at large, keeps him out of trouble with the law and allows him to establish some level of material comfort for himself.
Sonny takes a subjective approach through heroin and the music of the blues. This has some advantages, certainly. His music is a great gift to those who hear it and reaches their souls. Sonny's choice to use heroin along with play the blues is predicated on some erroneous propositions, however, in that he feels in control when using heroine and he feels that with heroin he can prevent himself from drowning in the sea of human suffering that besets us all--some more than others. Sonny has a false equation built on false propositions and the falsity is shown in his life as he walks out the prison door.
The narrator though comes to see the truth of the other equation at work in Sonny's life and that is that the blues saves him from drowning in the suffering by letting him embrace the suffering and turn it around to become something worthwhile in his life and for those who hear it.
The debatable postulate in Sonny's life (and perhaps in James Baldwin's theory) is whether embracing suffering to make it one's own is the only to learn from it--perhaps that is how one drowns from it. The narrator is an algebra teacher so that the two approaches can be comapred and so that the nature of suffering can be explored in its true and false equations.
Algebra is used to describe relationships between things that vary over time. The bother's relationship has change over time.