Q:

Why didn't the Persians create good infantry units?

The defeat at Marathon, Plataea, march of the 10.000, and the hold up at Thermopylae really suggest the need for some heavy infantry that can fight on par with the Greek Phalanx.
Like how much of your infantry really needs to be very mobile? 
The battle of Gaugamela also displays the ability of the Greek heavy infantry to deal with flanking manuevers, sort of.

A:

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.

A:

Question: Why didn't the Persians create good infantry units?
  The defeat at Marathon, Platea, march of the 10,000, and the hold up at Thermopylae would really suggest the need for some heavy infantry that can fight on a par with the Greek Phalanx. How much of your infantry really needs to be very mobile? The battle of Gaugamela also displayed the ability of the Greek heavy infantry to deal with flanking maneuvers

Why didn't the Mongols or Huns develop better heavy infantry?  It was the style with which they were successful, and that model (horse based archers) remained effective long after the phalanx had disappeared from use.
I would argue that the Persians were a very successful and very respected military empire.  They had battled and defeated both the Assyrians and the Babylonians.  They had held off the Egyptians and they even gave Rome all they could handle in latter years.   You don't conquer a large empire like Persia without having a very good army.
Yes, their heavy infantry was inferior to the Spartans at Thermopylae and Marathon but that's hardly a knock on the Persians.  The Spartans went centuries without one of their armies losing.  The Spartans were basically a military cult.   Their entire culture and way of life was based around training for war.  They even defeated the Athenians.
The battle of Gaugamela doesn't support your thesis.  At Gaugamela, the Persian infantry was engaged with Alexander's phalanx.  Alexander was commanding the companion cavalry and it was the use of Alexander's cavalry wedge which defeated the Persian infantry rather than the phalanx.   The Persians were engaged with Alexander's phalanx and he flanked them with heavy cavalry.  
In fact Alexander's phalanx with its longer spears were used to hold enemy units in front of them in order for his cavalry or archers to attrite them.   Again this is not a knock on the Persians.   I don't think it's a sign of incompetence to lose to Alexander the Great.  
Alexander's two big advantages were: 

He commanded a full time professional army where other armies at the time were made up of farmers, or only part time soldiers.  Alexander's father had built that Army and had trained Alexander how to use them.   Their great innovation was not the Phalanx either.  
The Other Macedonians innovation was they had mixed units.  Where other armies consisted of predominantly one kind of unit, the spartans basically used the phalanx and that's it.  The Macedonians (Alexander) had heavy infantry, light infantry, heavy cavalry and light cavalry.  They were flexible.  Alexander was the first to use field artillery, siege weapons modified to be used against infantry.  The Macedonians could put units against their enemies which maximized their enemies weaknesses.  Heavy infantry was just one of the kinds of unites in Alexander's army.  Alexander himself fought commanding cavalry;  his companion cavalry.  (heavy cavalry)

A:

The Persian army at Marathon was (as at Thermopylae) at a serious disadvantage because of the terrain, which favoured the much smaller defending force tremendously.
Their failure to win in both cases is more to blame on the leadership insisting on frontal assaults on a narrow front against a force trained and equipped specifically to deter such an assault rather than on the forces sent to fight that assault.
A better commander would have recognised that and kept a blocking force in place himself while sending the bulk of his forces in an encirclement in order to outflank the Greeks.
Why the Persians elected not to do this is a matter of debate among historians for a long time.
Maybe they'd grown overconfident after decades or more of military successes, maybe they were cocky thinking those puny numbers of Greeks could never stand up to them, maybe they were under pressure to provide a quick victory.
Individually, I seriously doubt a Greek soldier was that much better than his equivalent in the Persian army. But the Greeks were employed much better, using the terrain to their utmost advantage where the Persians did not.
Remember also that both Greek victories came after heavy Greek losses in earlier engagements where similarly equipped and trained Greek units were wiped out by the Persians in pitched battles.

