It is happening because he has been a drug user for some time. It is happening because he did not sustain his recovery. It is happening because he is impulsive and on some level, he believes he is invulnerable.
He may have been doing "good" but that does not mean he did not want the drug and indulged his craving. He does not want recovery in the same way that you want it for him. He wants it until he wants the drug more.
All of us are in the same boat. We want things for our children that they do not want (enough) for themselves. This is exactly my own situation. I am completely flummoxed why my son doesn't want (enough) to live in a house, to be warm, to have self-respect, and the respect of others. There is only one reason why. He doesn't want it enough. He may never. These are my wants for him. Not his for himself. Until we get it through our head that they don't want what we want we will suffer endlessly and terribly.
I still suffer endlessly and terribly. I guess that is the truth. But at least I know why. And I have days and hours where I do not suffer at all. If I tell the truth. But today is not one of them. My son is homeless in the terrible rain and cold. I went to look for him, without luck.