You're wrong to claim with certainty that the Persians wanted to add 'Greece' - which as a concept didn't even exist at the time - to their own empire. You're are also wrong to imply that the Persians were entirely unsuccessful in their campaign against the Greek City States.
I've saved some comments on exactly this subject by ancient historian Dr. Roel Konijnendijk and some others:
When we're talking about the Persian Wars, we should always bear in mind that we're pretty much restricted to a single source. The only narrative account of the Marathon campaign and of Xerxes' invasion is Herodotos' *Histories*. This was written some two generations after the events; it is informed by the conventions of epic poetry; it also appears to have various agendas to push. We should be very critical of its claims, and bear in mind that we're reading the Greek perspective on the policy of an empire that was larger, wealthier and more powerful than the Greeks could properly understand.
This is particularly relevant when it comes to the Persians' motivations and methods in fighting wars. There's an excellent chapter in Van Wees' volume *War and Violence in Ancient Greece* (2000) in which J.E. Lendon points out that Herodotos seems to be judging the Persians entirely by Greek standards of interstate relations, and their focus on perceptions of honour and righteous retribution, apparently unaware that very different concepts were in play for a state so culturally different and so much larger than any Greek polity.
With all that said, let's consider the Marathon campaign.
After the final surpression of the Ionian Revolt in 494 BC, the Persians returned to business as usual, which meant a resumption of their expansion into the Aegean. In 492 BC, Mardonios led an expedition into Thrace, conquering Thasos and Macedon, before his army was destroyed by Thracians and his fleet was lost in a storm off Athos. In 490 BC, Datis sailed into the Aegean, conquered Naxos (which had been the aim of the aborted expedition that triggered the Ionian Revolt in 499 BC), and continued westward, seizing the whole of the Cyclades, invading Euboia, reducing Eretria by siege and razing it to the ground. He then landed at Marathon, but the sailing season was nearing its end, and after losing a single pitched battle and being pre-empted in an attempted landing at Athens he quickly withdrew his force to Asia.
The Greeks regarded this expedition as punitive, thinking the target was always Athens, and that the Athenian victory at Marathon infuriated Darius beyond belief. We have little reason to believe this was really the case. The campaign was, overall, a great success; almost the entire Aegean had become subject to Persia. Since the landing in Attika happened so late in the season, it is not certain that the Persians ever intended to capture and pacify the region, which would have been the first Persian stronghold on the Greek mainland. We don't really have any idea how many troops were landed, so we can't tell what they would have thought themselves capable of. Possibly they were looking only to scout or raid the area. Possibly they were hoping Athens and the rest of Greece would simply yield, as the Macedonians had done when Mardonios arrived in their lands.
However this may be, the point is that Marathon was unlikely to be regarded as a major setback. The failed hit-and-run invasion simply offered no plausible comparison for a full-scale fleet and army campaign against mainland Greece. In any case, its result was contrary to all previous experience. In the past, Persian armies had *always* defeated Greek forces. They won four separate field battles against Greek or partly Greek armies during the Ionian Revolt. Herodotos makes a point of mentioning how incredible it was that the Athenians even dared to stand their ground:
These are the first Greeks whom we know of to use running against the enemy. They are also the first to endure looking at Persian dress and men wearing it, for up until then just hearing the name of the Medes caused the Greeks to panic.
-- Hdt. 6.112.3
The Persians would not have thought that their methods were at fault after a single defeat in a battle they barely committed to. Rather, it would have seemed to them that where a small invasion force had failed, a full royal army would easily succeed.
---------
To properly answer this question, we have to actually ask ourselves what failures the Achaemenids actually experienced, as well as any general difficulties. The reason for that is that when treating Darius' and Xerxes' campaigns as failures they are often not examined in depth as to exactly what failed within them, what objectives were not met. I would argue that least initially, Xerxes fulfilled a number of his initial objectives. However, I would still call both expeditions failures, and through exploring that I think we can give a basis for an answer to your question.
The initial expedition began with occupations of Greek islands, along with a renewed presence in Thrace and Macedon. This was done without great difficulty. Darius also opened negotiations, given the strength of his position, but both Athens and Sparta killed his ambassadors. This then altered the original idea- initially a number of Greek cities were being punished for interference in the Ionian revolt, but after Athens and Sparta did such things their punishment was sealed. The full attack on Greece successfully attacked Naxos, pacified Delos, attacked Karystos on Euboea and made them capitulate, besieged and took Eretria on Euboea due to treachery, then landed at Marathon. There they were defeated; the disaster was not total, but it represented a halt to this expedition against the Greeks.
Now, it's worth pointing out that the Persians army had done a lot of what it sought to do- subjugating Greeks and enacting vengeance on states that had aided rebels during the Ionian War. Herodotus' numbers for the expeditionary force are never given, but his given numbers of triremes (600) would presume a force of perhaps 26,000 men at most which is a fairly reasonable figure. We tend to discard other ancient estimates of 200,000 men as ridiculous. Herodotus' own estimation of Persian casualties was around 6,000 men, which would be around a quarter of the army's strength or less. Modern estimates trend towards 4,000-5,000, which is a lower proportion still. In other words, the Persians did not actually lose many men. However, it is worth pointing out that 20-26,000 men is not an enormous army for the Persians- this has the makings of a reasonably well equipped and semi-professional expeditionary force, not the full royal army. It was no doubt expected to succeed in perhaps grander fashion, but we are not dealing with the full might of Persia concentrated against Athens. Athens and Plataea together put forth around 11,000 men onto the field by themselves, and you can plainly see that this force was always unlikely to conquer the whole of Greece by itself.
But this was still an embarassing setback. Perhaps Darius had indeed assumed that the expedition would achieve a much more comprehensive solution to his issue. Darius did not get the chance to try another attempt, dying within 4 years of the battle. Thus we pass to his son Xerxes' expedition.
The march across the Hellespont was totally unopposed, and supplies had been laid out for the expedition well in advance. For that initial 480 BC campaign season therefore, Xerxes was probably able to field anywhere between 150,000-200,000 men, and this *is* a flying-the-flag royal army. Whether we believe Herodotus that the King of Macedon warned the defending Greeks of them being overrun or not, Thessaly was abandoned by the Greeks defending against Persia and thus Thessaly submitted. Many cities, in fact, submitted to the Persians rather than fight them. However, Thermopylae caused the Persians a delay of several days- given how slow a march is with an army of that size, this was certainly not a desirable outcome for them. The Greeks, as it happens, could not afford to sacrifice an army of c.5,000 hoplites even in this cause; even after the pass bypassing the Greeks had been discovered, Thermopylae was actually fortified at both ends and could conceivably have held out a long time delaying Xerxes even further. But the Greeks would have certainly been lost there one way or another. So the Greek strategy of taking the Persians head on was extremely risky and had to be very carefully judged. The Persians, in this campaign, were also fighting Greek fleets- the Athenians and Corinthians both now had large navies, and by the standards of the day the Greek fleet actually put to sea was quite sizeable. Whilst Thermopylae was ongoing, the Greek fleet eventually fought the Persians at Artemisium, and whilst they gained no clear victory Herodotus does assert that they inflicted pretty much equal casualties on the Persian fleet. Nonetheless, the Persian occupation of Greek continued- Boeotia submitted, and those cities that did not were destroyed. Attica was next- Athens was razed to the ground, and now only Sparta of the two ambassador-killing cities remained standing. But it's not long afterwards that the battle of Salamis occured at sea, and the Persians lost. Again, this is not a total disaster- this is not the loss of the entire fleet.
However, this did represent a significant loss of sea power and a much lesser ability to protect the pontoon bridge that had enabled the crossing into Europe. It's also at this point that Xerxes and his army has to return. Now, the victory at Salamis is often cited as why, and I'm sure it certainly contributed. But even with the supplies being set out in advance, the Persian royal army could not remain in Greece indefinitely. The king most certainly couldn't- Greece was a frontier, not a capital, and even though the Empire could be governed in his absence he was still its epicentre. In addition, the army that Xerxes brought probably included a large number of additional levies who would need to be returned to the Empire. Not that they'd couch it in such terms, but the removal of so many from the Empire would have had a really massive impact on its economy, not to mention the continued expense of feeding, clothing, and partially arming the army. But even after this, most of Greece was pacified and/or submitted. Mardonius, remaining with a smaller occupation force, might well have been reasonably confident. The task was nearly complete. But he did not have the naval supremacy to allow a landing beyond the Isthmus wall that had been build to protect the Peloponnese, and the Greek allies were still mostly intact (by the skin of their teeth). His army was then defeated at Plataea by the largest force of hoplites yet assembled by a Greek army, some 40,000 hoplites of various origins, and the remaining Persian fleet was defeated at Mycale. The expeditionary force was removed, and Xerxes was (fairly justifiably) not seemingly in a mood to spend such effort on another ruinously expensive expedition to what was to him the frontier.
My main issue here has been to establish that actually on both occasions the Persians came close to achieving their objectives in the scope of the resources available on both occasions. However, you have to remember that to the Persians the Greek world was the frontier. It was thousands of miles away from Persia or any of the Persian capitals. It was also nowhere near as rich, developed, or strategically important as most of the Empire's active possessions. This was not Egypt where multiple expeditions could be raised to recapture it when it revolted. It is pretty much exactly the equivalent of the Romans constantly attacking the deeps of Germania- whilst expeditions occurred, they were certainly not constant. In addition, the Greeks facing Xerxes' expedition in particular made some wise choices- they preserved the core alliance rather than breaking up, they persevered despite in some cases exile from their own cities, their methods of warfare were still mostly unfamiliar to the Persians and well suited to their own home turf, they realised that naval power was deeply important to the conflict. They also avoided catastrophic defeats, along with open-battle confrontations with the full Royal army- their pitched battle at Plataea was against Mardonius' satrapal army, against which they could presume more reasonable parity.
I do not really think the Achaemenids performed poorly. I would however say that their resources were stretched purely attempting to operate in Greece- none of the carefully constructed administrative and logistical network of the Empire existed there, Greece was really not very rich in that era by comparison to the Empire or fertile for that matter, and the primary intention of the expeditions were to pacify a troubled frontier of the Achaemenid Empire. Their impetus for acting in Greece was the Greek interference in the Ionian revolt, and internal affair- you are not going to leave powers attempting to affect your own state's internal workings unmolested. Greece was never going to be the equivalent of Media, Babylonia, and Lydia- settled regions with much to offer the Empire, and importantly MUCH closer to the Empire's capitals.
I don't think that Greece was ever, in this period, a match for Persia. If they had really considered it worth their time, the Persians could have just simply sent invasion after invasion. It's important to remember that only one Persian expedition came over the sea, and it almost succeeded. I don't think the successful resistance of a Greek coalition (it was never *the* Greeks as many capitulated or sided with them, and indeed Herodotus says that the Persian army at Plataea had Greek allies) was inevitable. But I also don't think the Persians were ever prepared to send army after army for a frontier land of rocky shores, poor soil, mountainous terrain, and very little riches. The primary purpose had always been to a) pacify Greece and b) to enact punitive measures on the specific states that had been assisting the Ionian rebels in their revolt.