With crossbows it was definitely about the ease of training. A couple of weeks would get you a deadly ranged unit. Compared to a master archer, a crossbowman is rather mediocre on the battlefield but you can crank out crossbowmen in a couple of weeks. Really almost anybody can learn to shoot a crossbow proficiently in a single day, but it takes more time to drill the loading procedure into them so they can perform under stress. With firearms it was all about the power. Accuracy was low, cost of manufacture was insane, the training was more lengthy and difficult than for a crossbow (this was long before pre-measured paper wrapped cartridges, and soldiers screwed *those* up constantly). The advantage a hand cannon has over a crossbow is that, when impacting the surface of the armor...it deforms. Where a bolt's sharp point will skate across any sloped plate and be deflected harmlessly, a lead bullet will smash flat against the surface and deliver far more of its punch to the target.
Guns replace crossbow because of range.
See above. Early firearms had *abysmal* accuracy. Each gun would be hand forged by a smith (or cast in a mold), then the bullets would be cast in a rough mold, and then you're aiming the thing more by intuition and experience than by using any kind of sights (the cannon was mounted on the end of a pole, which you clamped under your elbow). Standards? Unknown. Manufacturing tolerances? Very very loose. Where a crossbowman's effective range versus a military formation might be, oh, say 150 yards. Handgunners might be around 50 yards. That's against a *formation*. For an individual target, halve that. A crossbowman uses sights attached to his weapon and aims very precisely, has his weapon braced to his shoulder for better control, shoots a projectile that is inherently self-stabilizing, and really only has to "guesstimate" the range to target and thus the amount he needs to hold over to get a hit. A bullet from a hand cannon is partially deformed on firing, so it flies irregularly, it's not spin-stabilized (Rifling? What's that?), and will spray out of the barrel somewhere in a vague cone shaped area.
Compared to the crossbow,
Rate of fire: Comparable
Power: Good.
Intimidation factor: Outstanding
Accuracy: Pathetic
Things improved somewhat with the matchlock, but hand cannons were already in wide use by the time those turned up.