The firing timing, the angle of the crank, that sort of thing. Along with the number of cylinders involved in providing the bangs. Why does a Lamborghini V12 sound pretty awesome, too, when pedalled properly?
Even the twins with different cranks have a slightly different sound. Think about Triumph Bonneville series, the Bonnie/Thrux with a 360 degree crank, and the cruiser models with a 270 degree one. Furthermore, the triples that sound great have not only an odd number of cylinders, but also a 120 degree angle crank. That makes the distinctive sound that feels like a two wheeled version of the Lambo.
As for the big bang inline fours, or like the new Yamaha R1 engine, they use different firing order and several different firing angles, like cyls 1 and 2 can be 180 degrees, and cyls 3 and 4 at 270 degrees respectively. Hence the slightly different sound and torque character of the two different inline twins. But still, they still don't sound as good as these triples, especially when revving well over 10,000rpm, like those Japs do. Suppose the great sound is just another little bonus you get when buying one of these eccentric bikes, or a Triumph triple.