TL;DR: It is not possible to identify the specific events or circumstances that motivated Euripides to write this speech.
The diatribe against the Spartans in Andromache was surely intended to have a contemporary political relevance:
But his [Euripides’] bitterest invective is reserved for Sparta and the Spartans. The characters of Menelaus and Hermione are painted in the blackest colours. In several passages (notably that which begins at l. 445) the Spartans are held up to universal execration. It is evident (as I shall show more fully below) that Euripides wrote the play at a time when the relations between Athens and Sparta were in a state of extreme tension, and that he meant it as a direct incitement of his fellow-citizens to further efforts against the common foe.
A. R. F. Hyslop (1900). The Andromache of Euripides, p. xiv. London: Macmillan.
Unfortunately we can’t be sure what this relevance was, because we don’t have a secure date for the play, and internal evidence is not compelling. Hyslop argues above that the play must have been written when “the relations between Athens and Sparta were in a state of extreme tension” but this description could refer to most of the years 431–404 BCE when Athens and Sparta were embroiled in the Peloponnesian War.
There is a scholium (a marginal comment in a manuscript) on line 445 that perhaps explains why we don’t have a date:
These lines were a pretext for Euripides, in the person of Andromache, to scold the Spartans for starting the war. […] It is not possible to fix precisely the date of the play, for it has not been produced at Athens. In his catalogue of tragedies, where he dealt with the plays of Euripides, Callimachus seems to have said that he had found a copy of Andromache inscribed with the name of Democrates; and that the Andromache of Euripides was not found in the didascalia. Nothing more can be gathered from the commentary.
Scholium on Andromache line 445. In Eduard Schwartz, ed. (1887). Scholia in Euripidem, p. 284. Berlin: G. Reimer.
The didascalia were catalogues of plays that had been performed at the Athenian Dionysia festival, giving the title, playwright, Archon and date (in the form of an Olympiad and year) of each work. If the scholiast was correct that Andromache was not performed at Athens, then it did not appear in the didascalia and so, lacking Archon or Olympiad, it was impossible to date the play precisely. However, perhaps the scholiast merely deduced this from the somewhat puzzling account of Callimachus. See James L. Butrica (2001), ‘Democrates and Euripides’ Andromache’, Hermes 129, pp. 188–197, for a detailed discussion of the scholium.
Some scholars have to tried to date the play based on internal evidence. Hyslop draws attention to lines 733-736, where Menelaus says, “There is a city not far off from Sparta which previously was friendly but now is hostile. I mean to attack it as general and make it our subject.” Hyslop suggests that this is an allusion to Argos, which was an ally of Sparta until 421 BCE but then turned hostile:
In 421 B.C. peace was concluded between Athens and Sparta. This was called the Peace of Nicias, and, owing to the discontent of some of the Spartan allies, was followed by a separate alliance between the two states. The discontent of Sparta’s allies increased, and led to the formation of a counter-alliance, which was joined by Corinth, Argos, Mantinea, and Elis. Sparta replied by uniting herself with Thebes. This gave Alcibiades his chance, and he engineered a counter-alliance between Athens, Argos, Elis, and Mantinea (B.C. 420). The result is matter of common knowledge. The year 418 B.C. saw the outbreak of war between Sparta and Argos, and the crushing defeat of the latter at Mantinea.
It is clear then that the years 421–418 fulfil the conditions required by the present play. They were years in which the tension between Athens and Sparta was great, and the neutrality previously
adopted by Argos towards the militant states was exchanged for a policy of active hostility to Sparta. As Menelaus says in the lines quoted above, “She was friendly before, now her acts are hostile; I will proceed against her by an expedition, and reduce her to subjection.” Her hostility was shown by the alliances of 421 and 420, and the expedition was that which ended in the battle of Mantinea and the reduction of Argos.
Hyslop, pp. xviii–xix.
However, this kind of internal evidence is not dispositive, since allusions, even if correctly identified, only give a terminus post quem:
The Andromache cannot be dated. There have been numerous attempts to give it an approximate date on the basis of “allusions” in the play to contemporary events. I find most such allusions ambiguous or nonexistent, and all of them highly untrustworthy as testimony to the year of the play’s writing or production. It is one thing to note a parallel between Menelaus’ desertion of Hermione and Sparta’s treatment of Corinth, Megara, and Boeotia in the Peace of Nicias, but quite another to place the play after 421 B.C. on the strength of that parallel. It could be argued as easily that Sparta “deserted” Corinth and Megara as early as 426, when she transferred her main attention in the war from the Gulf of Corinth and northwest Greece to the Aegean Islands and the Thraceward regions. Our best evidence, a scholiast to line 445, says that the play was written at the beginning of the Peloponnesian War, i.e., closer to 431 than 421. But even he could not “absolutely” place it, and so the date must remain a mystery.
Keith M. Aldrich (1961). ‘The Andromache of Euripides’. University of Nebraska.
The other means by which one might try to date the play is through its style. Euripides’ poetic style changed over the course of his career, and some scholars have tried to use this to date the play:
Zirndorfer† also puts the date of the Andromache in the second year of the eighty-ninth Olympiad [422 BCE], inferring this date from the metre and from the political allusions. He finds that in the matter of resolutions in the trimeter the Andromache stands between the Hecuba and the Heracles. He puts the Hecuba in the last year, of the eighty-eighth Olympiad [424 BCE], the Heracles in the third of the eighty-ninth [421 BCE], thus leaving for the Andromache Olympiad 89.1 or 89.2 [423 or 422 BCE].
Grace Harriet Macurdy (1905). The Chronology of the Extant Plays of Euripides, pp. 78–79. Ph.D. thesis. Columbia University.
† Hermann Zirndorfer (1839). De Chronologia Fabularum Euripidearum. Marburg. See the table of dates on page 123.
However, stylistic methods don’t give us anything like the precision we need:
It is of course impossible to date a play definitely in this fashion. The number of resolutions in the trimeter is an important general indication of the period in which a play was composed, but neither consciously nor unconsciously could Euripides well have used a fixed arithmetical progression in the number of resolutions which he permitted himself in writing his dramas.
Macurdy, p. 79.