archers have more range and more ammunitions, bows and arrows cost perhaps a little more but even pre-historical men use bow and arrows :x.
On mobile right now so I'll pull up some sources later but what you should take away is that there are both strategic, tactical, and logistical reasons to explain the predominance of either in ancient armies.
Firstly, the classical Greek army is centered around the citizen soldier hoplite. Heavy infantry was the dominant mode of warfare between city states, and thus they focused their resources to developing this arm more than others. Think about the fight between phalanx and phalanx. It is a shoving match with spears and shields, raising a great cloud of dust, and the side with greater discipline and cohesion usually won. Light infantry, peltasts and missile troops, usually filled skirmishing and screening actions that preceded the battle to inflict casualties, harm morale, and break cohesion. But the main battle was nearly always settled between the heavy infantry. This explains the relative lack of sophistication in Greek missile.
Secondly, javelins were by far easier to teach how to throw than bows and arrows. It was an Olympic event, many of which are inspired by martial tradition. The basic action of the javelin throw requires less precision than the bow, a weapon which requires extensive exposure to master. English longbowmen, Cretan archers, etc., trained extensively (many since childhood) and their expertise made their services a highly lucrative source of income. Contingents of Cretan archers served in Caesar's legions and Alexander's armies to augment the ranged wing. To become a proficient war archer requires a time and energy investment many Greeks did not have. By contrast, the rudiments of the javelin come more naturally to the human body and with a heavier warhead and shaft weight, it offered greater disrupting, killing, and penetrating power at the closer melee distances. This was one of the primary tactics of the highly versatile Roman post-Marian legions, a corps composed of young soldiers with no heritage of combat training prior to joining the legion.
The peltast also doubled as light melee infantry in skirmishing actions, armed with the large hide shield. This is advantageous compared to the archer who is already burdened with his bow and arrows, a weapon that requires both hands and a cumbersome combat load. Alexander made heavy use of them in rough terrain where heavy infantry was disadvantaged, such Bactria and Afghanistan.
Mods, please remind me to add sources as I'm late to an obligation.
Source:
Land Battles in 5th Century BC Greece: A History and Analysis of 173 Engagements by Fred Eugene Ray, Jr.
https://books.google.com/books?id=NECnIjWtIMEC&lpg=PP1&pg=PA7#v=onepage&q&f=false