If you're in the same boat as me you probably thought that meursault getting the death penalty was a bit extreme. Surely there was some other form of punishment to fit his crime? Initially that is what I thought, but after further thought I have realized that nothing but the death penalty, or life in prison, could suit meursault's crime. It is not because it he killed a man. Plenty of the people do that. It is that there is no possible way he could be reconditioned or reformed to go back into society and not be a hazard to people around him.
If the purpose of prison is to punish and reform then only half of that could apply to meursault. It is easy to punish someone for a crime. Once you figure out the correct course of action a fitting punishment can be applied. However, if your intention is to reform the criminal and return him to society a changed man then the punishment may change. There's the possibility of parole or reduced sentencing.
This would not work for meursault because he exists outside of the expectations of society. He could be punished and returned to society only to then be set back to square one. There would be no reforming him because his crime wasn't caused by something that can be reformed. To the court in Algiers he is so disconnected from "normal" living that the best course of action is to remove him from society. In this case they do so by executing him. For them it might have been a tough decision. To meursault it didn't matter, so why return him to society?