We should possible compare crossbows, bows and firearms during times when their corresponding versions were contemporary with each other and used in the same region of the world.
For the 16th century naval weapons among the Maghrebi Arabic were firearms, arquebuses, for long range and bows, recurve, for short range.
A similar arrangement between bow and firearm can be found in Japan with Toyotomo Hideyoshi, albeit the bows decreased in his second invasion of Korea. The Japanese tried to fight it at land, Koreans at sea. The Koreans had cannons, unlike the Japanese, but used archery instead of muskets.
Light mounted troops in the 16th-17th Polish-Lithunian Commonwealth often carried bow and pistol. For them the firearm was a shortrange weapon while the bow was for longer ranges.
All these soldiers were aware of expenses and capabilities of their weapons and made choices that under certain conditions one or the other suited better.
So far I didn't mention the crossbow. Thalhoffer has a nice ilustration in his section on mounted combat that shows a lancer without a
shield holding the lance head high and slanting down in order to deflect the bolt of a crossbow aimed at him by another mounted soldier a short distance away. This picture illustrates that a fencing master could claim that it was possible to defend oneself against crossbow bolts. This applies even more so to arrows from a bow. Their projectiles are roughly in between 100-300 km/h(62,2 mph to 186mph) fast. That's the same speed as a ball in lacrosse or pelota(before being deflected on the wall). It's not impossible to catch these projectiles and they are balls, not bolts or arrows which are even better to catch. I don't want to claim that it's possible to defend against all arrows and bolts, especially if they come in a thick shower, but it's neither impossible. A central part of that defence is the shield and this is a nice article on its origins and developments:
http://www.prm.ox.ac.uk/Kent/shieweap/shgenex3.html Please note there are societies who didn't have shields in our sense, but rather "defensive sticks". The efficiency is again depending on the volume of projectiles faced.
Back to firearms, they pose a problem that has been discussed in military literature of that age: a defense against bullets. There are several ways: strengthen bodyarmour, do some magic and become quick enough to catch them. All were tried, an example for bodyarmour are the European cuirassiers, magic was for example used in the 30years war in order to become a "frozen one", someone whom death would do no harm, and finally the so called boxer-rebellion in China. Well, none worked, the armour approach worked best, but it became heavier and heavier until it was discharged and centuries later reintroduced with much lighter materials. So the issue about firearms is not if they hit, but that there's no protection against them, especially at short ranges.
Looking at the early Spanish tercio, we have the firearms among the skirmishers and the javelins among the troops of the line(javelins are compareable to crossbow bolts, but heavier). During the 80 Years War the development was that the arquebus become a weapon of the line and the skirmishers had musketeers, who in turn became also troops of the line with the Dutch and Swedish military development. The important common issue is that the skirmishers always had a weapon against which it was hard to impossible defend. This development was possibly started with the heavy crossbows in Europe who are claimed to have been able to go through shield and armour (likely an exceptional event because in Nuremberg armour had to proof being able to withstand a crossbow).
The unsolved problem with handheld firearms until the introduction of the Minié ball or widespread powerful airguns was long range accuracy. In this field both bow and crossbow could excell, but the problem was not hitting, but wounding enough to be worth the energy spent. This had to be weighed against the possibility of doing quick damage at close range, for which the bow was very good, but the crossbow was also useful, as the Hussites showed. All three weapons could easily be handled at close range, But not all were equally effective over long ranges, that depended very much on the terrain and the enemy's equipment.
The handheld firearm had from early on one advantage that has been pointed out already, it was difficult to destroy, so holding it in harms way for the weapon didn't disable from using it again. Thalhofer shows the crossbow being similarly used against a lance, but it's not clear whether the prod is undamaged.
There may have been a mental problem, the more difficult it was to make a weapon ready for combat, the more likely were errors, even more so if this task had to be done while personally being threatened. This applied to Korean archers claimed to be running away after the first shot because the Japanese infantry approached so fast, to early firearms that were quite crude and simple, but still their operators were well paied specialists recruited from chosen regions. Bows and crossbows used at short range are not so prone to mismanagement, especially bows, but long range skill required specialists who were with both weapons payed more than the ordinary spearmen.