The reason is you have no strategic resource for a sword or horse, or you need bodies faster, or you're fighting in forests and jungles where you can make use of Woodsman. They're army filler, but they still have a role to play.
Yeah you could argue the main "problem" with pikes is the xbow, and I don't even mean the counter. I mean as a relatively inexpensive resourceless unit, once you have xbows its become harder to justify making pikes. They in some ways become the generally spammed unit.
You mean versus knights? C bows get bowled over by knights, you really can only use them in cities or if they are well protected.
They can try and whittle down some of the initial knights if you have enough of them (which is often your main defense against knights if you've been outteched), but they cannot hold their ground, once the knights get to them they get curb stomped. Pikes can at least hold their ground and take a few shots.
Pikes can't really attack (unless a skirmisher/siege unit is standing right in front of it, in that case you valuate whether it's worth the trade). Their job is to hold the ground and hopefully survive (and earn some XP) while ranged units shoot from behind.
The issue is you only need a tiny number of units to hold the ground in the first place. Unless you have literally zero strats there is little point making pikes. You can just put comp bows in the front and pull them back when damaged. It is only slightly worse than mixing in pikes as the pikes can't really attack or do anything useful.
With the right flanking they do. But even 2 shot, I mean the AI often brings enough forces to hit the unit twice, and then its dead.
There isn't a way to hold a line with cbows against knights unless you have a LOT more units than they do (which never happens on higher difficulties at that point in the game). you just have to pull back or you will get crushed.