The longbow had a range of about 200 - 300 yards and fires much faster than 3 rounds per minute (standard fire rate for muskets in a trained soldier's hands). The battles at the time, due to lack of accuray and the number of ammunition a musketmen could carry, the musketmen shot at each other at a range of 50 yards. So, on paper, it would look like that using longbows would have been better than muskets until the Mexican war and Civil War.
However, that wasn't the case. As many have said, it took 1/2 a life time to train a soldier that can fire the English longbow 200 - 300 yards with some accuracy, while in a training camp it would take about a week to get used to firing a musket 3 rounds a minute. (a day if you do nothing else, but soldiers at camps needed to work on other techniques: bayonet charge, counter-cavalry formations and bayonet thrusts, marching in formation, etc.)
Secondly, the Longbowmen had almost no melee ability. They used daggers for self protection. Except Agincourt, where the French Men-At-Arms were stuck in the mud allowing the no armor Longbowmen to use their dagger efficiently, the Longbowmen could not fight and win a melee battle. During the 17th and 18th and early 19th centuries, a bayonet charge was actually more effective than vollies. After fixing a bayonet onto a musket, a musket can now used both as a gun and as a short spear. You can't do these things with a Longbow.
Now as for the Longbow's long range ability, it was inferior as cannons were introduced. During the battle of Formigny in 1450 of the Hundred Years War, the French proved this point by disrupting the English Longbow formation with cannon fire from out of the Longbow's range. You can say the Longbow wasn't replaced by arquebuses and muskets, but by cannons, which also replaced siege weapons.
There were also other little things about the Longbow. A longbowmen has to fight standing up, in other words, he cannot entrench. The musketmen rarely entrenched during the pitch battles that lasted up to the Napoleonic Wars, but they can when they want (kneeling down behind stone walls and such. Neither musketsmen nor longbowmen can fight lying down, but at least musketmen can kneel)
A bowmen has to keep their bowstrings dry or the weapon would be much less effective. Same as the musketmen have to keep their muskets dry, but a longbow string is exposed while a musket barrel is not. Even worst the string cannot be moistened either while the the musketmen just have to worry about the powder getting wet.
Back to the training length problem. With the introduction of larger, more massive armies, the longbowmen can not be trained fast enough to meet the demand of troops while the musketmen can.
Lastly, longbow has to fire in open space so their bows and strings wouldn't be tangled in vines, branches, undergrowth, etc. The musket didn't have the limitation.
Did you know: Though accurate to some extent, generals counted on the longbowmen to fire a blanket of arrows - a volley - at enemy massed formations rather than firing to hit individual soldier. It is the same thing as an artillery barrage, fire at the formation with a blanket of fire, not an individual.