The carbon and sulfur in black powder are reducing agents, while the potassium nitrate is an oxidizing agent. The reaction releases lots of heat and gaseous products, which makes it possible to use the mixture as an explosive.
I think the reason why sulfur is added in the mixture is because it speeds up the combustion. I actually once made a mixture of KNO3 and carbon without sulfur, and it seemed to burn like black powder but slower.
Note that in physicsforums we are not allowed to discuss in detail how to make explosives...