In hindsight, the Ancient Greek heavy infantry were vastly superior to the Persian armies. It was precisely their battles - Marathon, Thermopylae, Plataea - that demonstrated this. Before those battles, no one knew that the Greeks had a superweapon in the form of the Hoplite Phalanx in their hands. The Greeks were busy fighting each other.
As great as the Persian Empire was, its military was not its strongest point, instead it was its immense size and wealth. Due to Greece's remoteness, standard procedure was to play the various Greek city-states against each other - for example, during the Peleponnesian War, the Spartans were bankrolled by Persia.
Persia's size was intimidating to the Greeks; when Aristagoras was appealing to the Spartans to aid the Ionian Revolt, he suggested that the Persian military, as we now know, was weak. But upon hearing that it would take three months to reach Susa - one of the four Persian capitals, the Spartans firmly refused to help.
It was only after the Greco Persian wars, and knowledge gained from the Ten Thousand, that the Greeks knew it was possible to beat Persia, but first it would have to be united. This was achieved under Phillip II of Macedon, who soon planned an invasion of Persia. He was assassinated, but he was succeeded by none other than Alexander the Great.
Again, Persia turned to its strength - wealth - to compensate, in the form of funding Greek rebellions and hiring Greek mercenaries. But the misfortune of having to go up against a military machine, armed with a superweapon (Macedonian Phalanx) and not just one but two of history's greatest military minds (Phillip II and Alexander) was too much to bear.
Could Persia have produced its own heavy infantry to rival the Greeks? Arguably they did; historians like Herodotus had high praise for the Immortals. On the battlefield, although they were weaker than their Greek counterparts, they still held up well. The Persians were beaten with a combination of great logistics and tactics. Alexander could strike hard and fast, and the Persians simply couldn't keep up. The Battle of Gaugamela is typical of this: the Persian army was holding well on all fronts except for Alexander's daring attack, which drove a wedge that headed straight for Darius III, who broke and ran. This battle says more about Alexander's abilities than the quality of the two armies.
Could Persia have recreated the Greek heavy infantry? This is harder to answer. There's a theory that it's very hard to recreate superweapons like the Greek phalanx, as you need a unique combination of culture and martial tradition. The Greek Hoplite was perfected over centuries of city-state on city-state decisive warfare, over mountainous Greece. Superweapons like the English Longbow or Mongol horse archer were also inimitable for similar reasons.
So I find it hard to fault the Persians in not coming up with a good counter to Greek heavy infantry. They found out about how scary the Greeks can be as soon as anyone else, and dealt with it in a sensible way - by using their unrivalled wealth and influence to keep the Greeks divided. Having to face Alexander the Great is also a big ask; when the Romans faced Hannibal, at least they had Scipio Africanus. The Persians had Darius III.