1. The Bandits Decided To Not Kill Him
In fact, they saved his life so that they can torture him later on for information, revenge, or simply because they are sadistic. The NPC who was with him managed to escape and informed the group of the situation. Now, this becomes a quest for the group of breaking into the bandit camp and saving their friend.
Alternatively, maybe a bandit member does not share the bandits' views and secretly healed him. Or, maybe one the bandits is actually a long lost friend/relative of the PC who saved him afterward and the PC did not recognize him/her in the heat of the battle.
2. Deus Ex Machina (in the form of NPC/creature/god)
Maybe an NPC happened to find the body and decided to help him. This NPC can be a simple traveler or a cleric of some god (bonus points if this particular god plays a role in the campaign). Maybe a creature with healing abilities found his body, dragged it over and healed for reasons unknown. Maybe a literal god was nearby for unrelated reasons, was intrigued by this heroic fool and decided to give him a second chance.
As @richardb very nicely added in the comments, whoever saved the PC might have done it because they are simply empathetic or because they have ulterior motives. Per his example, the NPC/creature/god that intervened now thinks that the PC owes them. This can create very interesting subplots, i.e., "Your life was saved, but at what cost?" dramatic music plays in the background
3. Not Dead But Crippled
One way or the other a player should be punished for making stupid/lethal mistakes. One way to deal with this would be to cripple him, at least for a few sessions. The idea is that the PC is not dead but lost a lot of blood (or any other excuse you want). The result is that now he has constant -2 in Constitution. You can be very creative with this. Maybe he lost a limb, or an eye/ear. Whatever the damage is it should have some permanent mechanical effect. E.g., the player now has a constant fear of the thing that killed him and has to make a wisdom saving throw every time he faces it.
However, the goal is not to leave the player crippled for the rest of the campaign (unless he enjoys that), but rather to create a whole new subquest for him to regain his lost abilities. He may use magical methods (i.e., grow a new limb) or train really hard and overcome physical and mental obstacles. This is how you change a bad moment into a story moment. However, make sure that your player likes the idea, this is not everyone's cup of tea.
Opinion
Like I mentioned in (3) I think that it's a good idea to somehow punish a player who plays stupidly. This is important because you cannot save every PC that dies. If you save your player's PC today, another player may feel that it's unfair when their PC dies for real. So, no matter the solution you choose, I suggest imposing a penalty to the PC like the examples I mentioned.