Two main reasons:
The protoplanetary disk from which planets and satellites formed was not homogeneous. Lighter elements and more readily dissociated molecules will be blasted away and/or apart if they are sufficiently close to the sun. The sun emits a great deal of energy, and UV radiation in particular, which is great at breaking up molecules and providing an energetic kick to lighter atoms and molecules.
So objects like Mercury, which formed close to the Sun, will be composed of different material than will objects that form further away. It's possible for objects to move from close to far, or far to close, though. This is basically why the Earth has any meaningful amounts of water: the late heavy bombardment consisted of a relatively large number and volume of icy objects that formed further out having moved further in (or developing a large eccentricity that brought them inward) and ultimately colliding with objects such as the Earth.
To the best of my understanding, Io is believed to have formed in the general vicinity of Jupiter, so would have had access to a lot of materials that Mercury simply did not. Sulfur and sulfur compounds in particular.
Why it has volcanism
Earth has volcanism, and a molten outer core, because of latent heat from its formation, radiocative materials in the mantle, and possibly other sources we don't completely understand. That's a simplification, of course, as I'm not even touching upon plate tectonics and all that, but we just want to contrast it with an object like Io.
Io, on the other hand, has volcanism due to internal friction generated by tidal heating from its elliptical orbit around Jupiter, which is maintained as elliptical (instead of dissipating energy and circularizing) via an orbital resonance with other Galilean satellites. The changes in the strength of Jupiter's gravitational pull on the planet variably stretches the planet, which stresses it and creates heat.
About that location...
So you might be thinking that if Io formed near Jupiter, which is beyond the (water) frost line, then why doesn't it contain large amounts of ice, or at least water? Well, the location is important for this, too.
Io is the innermost of the Galilean moons. Europa, the next closest Galilean moon (and one of the ones Io is in a resonance with), is more than 1.6 times as far from Jupiter as is Io. This means it receives significantly more incident radiation from Jupiter than the other moons do (Europa would receive only approximately 37% of the radiative energy that Io does). This radiation was sufficient in the early period of their lives to do what the sun's radiation does: blast water apart into hydrogen and oxygen (and then starts blasting the hydrogen away). As such, while Io would have had access to a number of ices, including water, for its original formation, most of it would have been lost to this radiation. Moons that are further out, or were captured by Jupiter much later in Jupiter's life, can retain their (water) ices, but Io was not so fortunate.
Thus you end up with a rocky, silicate-heavy world that's devoid of ices but has significantly more sulfur than an inner planet like Mercury. The sulfur becomes pronounced in the volcanism for chemical reasons: it's volatile and pretty easily becomes gaseous. And it doesn't need to have volcanism that behaves like volcanism on Earth because the source of its heat is fundamentally different.