Rome.
The Roman's used the phalanx themselves but soon devised a better tactic after their defeats at Caudine Forks. It was clumsy and had serious weakness to flanking. So, being innovative, the Romans worked on it and evolved into a 3 line fighting stance, known as a Legion. It was more flexible than a phalanx, which gave Rome the edge as it invaded Greece. The Roman's still used the phalanx once in a while, usually with tertiary units or reserves.
When Rome conquered Greece, any armies raised in Greece would be raised under the Roman Legion model instead of the traditional hoplite phalanx model.
Source: J.E. Lendon Soldiers & Ghosts: A History of Battle in Classical Antiquity
"Greek phalanx" is a bit general. Your bog-standard formation in the classical period (5th C BCE Greece) was a formation of close-order hoplites, 8 men deep. In the 4th C the Thebans introduced a few variations on that deployment, one by increasing the depth of the formation to 16 men deep (probably to give greater momentum and impetus in the charge) and refusing the weaker flank.
It was also during the Peloponnesian war that we see awareness of the vulnerabilities of the hoplite phalanx when an Athenian force was wiped out by... I want to say Thracian peltasts (light infantry). Later the Athenians did the same by decimating a mora of Spartans on Sphacteria using light infantry back up by hoplites. You get some experimentation possibly under Iphicrates with some kind of hybrid hoplite/peltast (we're not certain).
But the main reason the 'Greek' or classical phalanx fell out was the Macedonians. They took the deeper Theban formation and combined it with the pike which resulted in a much nastier force. But more importantly they fielded an 'all-arms' force with good heavy cavalry, light cavalry, good skirmishers. In the classical period you rarely find Greek cavalry or light infantry having any effect in battle (aside from the pursuit of broken enemies). Under the Macedonians the heavy cavalry were very effective.
States began adopting the Macedonian style pikeman but also a new type of soldier that was a hybrid between the pikeman and skirmisher called a theurophoroi.
Of course all this was then disrupted when the Romans with their manipular legion showed up and wrecked everyone's shit. You then find 'imitation' legionaries showing up in some states being organized/taught by Romans.
Edit: I didn't actually answer your question of "why" (doh). Well the classical phalanx was inflexible and not easy to maneuver around on the battlefield. It was also a militia comprised of citizens which results in uneven training and lack of cohesion in newly formed armies. The Macedonians had defined formations (roughly 1,000 men if I remember rightly) who became effectively long-term soldiers. This means you have veteran formations with very strong cohesion. The Roman manipular armies were even more maneuverable and were deployed in supporting lines.
I'll ask the question, why was the phalanx so strong? During alexanders time, when this formation won so many battle was because it was balanced with lots of calvary and auxiliaries like slinger. Back then, greek armies were very well complemented in troop composition. And with tatics like the anvil and hammer, many victories were won by Alexander and his generals. Later on in roman history, the hellenistic powers generally had weaker army compositions, such as having much less calavry in the 200 bc. Planaxs alone are cumbersome and inflexible when not back up by calvary and lighter troops to pin the enemy in place. So the main reason why the planax was fazed out was because it wasn't incorporated in the armies of time, making them less competent againist the more maneuverable and flexible roman legions. A great example of this is the battle of cynosaphalae. Source - in the name of rome