If I may ask further, was the change related to the rise of firearm technology, bayonet technology, some combination thereof, or something altogether?
Thanks for your replies.
The "when" is a bit tough as it was not an overnight change. Pikes were used in large number because throughout the Medieval Era and late Renaissance cavalry was, by all accounts, the leading power on the field. Even with massive pike formations cavalry could rule the day. Thus infantry was formed into tremendously deep squares of pikes mixed in with bowmen, swordsmen, crossbowmen, etc. to give it flexibility and, in the mid-late 17th century, supported directly on the front with light cannonry.
Also in the 17th century though came the rise of the gun, the matchlock musket. It was so incredibly heavy it required a stand at all times to hold it up. You'll also notice in said illustration that there is a large piece of rope attached to the rifle. That is the ignition mechanism. As you can see in this video bit loading a matchlock was/is an incredibly tedious process. You need to pour loose powder into the firing pan, then close the firing pan. Then pour loose powder into the barrel and stuff in a bullet and cloth (he does not do this in the video as he is dry firing). Then you need to stick the rope into the hammer and blow on it gently to maintain its ember. Make sure you give it just the perfect amount of give or it won't hit the flash pan right and won't even fire! Then you open up the flashpan again and fire. This would lead to load times of, in perfect conditions, 45-60 seconds and in combat more.
So why were guns used at all and how were they used? Because they're terrifying! These guns are loud, stupidly loud. Far louder than any gun today or that you see in Hollywood action movies. They also produce a lot of smoke. A shit ton of smoke. Especially in the pre-Napoleonic era and even post war was, in many ways, far more concerned with morale than just straight up killing as many people as possible. It's not killing a hundred of the enemy it's about killing them all at the same time with a thunderous boom and a billow of smoke. Imagine being in some pike formation and you're slow marching up to this enemy pike formation (can't run too fast or they'll counter charge and tear you apart) and your eardrums practically burst, you can't see the enemy anymore from smoke, and half a dozen dudes right next to you all slump over. That's fucking terrifying.
So guns were integrated into pike formations. By the 30 Years' War (1618-1648) most pike formations would have a 1:1 ratio of musketmen and pikemen. Musketmen would run out, fire their shots, and retreat back into the pike formations for protection from cavalry and enemy infantry.
So why did this go away? A few simultaneous advancements happening at the tail end of the 17th century. The flintlock musket, for one, would come into the scene. Much simpler than its matchlock counterpart it did not require the complicated rope system of keeping an ember going nor was it so large and clumsy. It required a simple spark from a hammer in the flash pan. It also allowed standardized amounts of powder that came in 'pouches' thus simplifying the reloading process. Men could now fire 3-4 rounds per minute consistently rather than 1 and at most 2 in best conditions. Add into that though the biggest of them all, the ring bayonet. The socket bayonet was one which stuck into the gun and thus literally turned a musket into a functional spear. The ring bayonet, however, went around the barrel and thus allowed the gun to be operational while also functioning as a 2-2.5 meter spear. This completely removed the necessity of pikes. Pikes were one dimensional weapons and required significant training for men to be cohesive with them. So were bows. They were all but defenseless against cavalry or infantry and thus needed protection from infantry.
Musketmen needed neither. They were both. They could bring hell upon the enemy from a distance with even more devastating morale effect than bow or crossbows while also protecting themselves from cavalry. Form a square and you are nigh-impenetrable. Further it only takes about a week to train someone to use a gun and a month to teach them the necessary formations. It would take decades to teach someone to be a good bowman and months to train to work in a pike formation.
TL;DR:
Flintlock muskets made muskets very effective personal killing machines which could slaughter other non-musket armed infantry formations. With the ring bayonet they could, in addition to that, at least hold their ground against traditionally armed infantry. By combining the roles of a pikeman and a bowman/crossbowman and with the reduced costs of forming an army out of musketmen rather than heavily armored pikemen muskets just naturally took over the pike and the bow on the battlefield. It did both jobs well enough.