Self defence.
To face a more powerful common enemy
They united 180 Greek city-states into several alliances, the first led by Sparta, the next led by Athens.
Pony express
Exercising his power of king through his generals.
It was in their interests to join with the other Greek city-states in a coalition to defend their mutual interests and cities.
Persian
Threat of annihilation by the Persian invasion
The war against Persia. It united all of Greece, including Athens and Sparta.
He built the Royal Roads
Against the Persian invasion.
They were already allies, Sparta had sent its army to aid the Athenians ward off the Persian attack in 490 BCE at Marathon (it arrived too late for the battle), and along with the rest of the southern Greek cities, they had a vested interest in uniting to repel the Persian invasion of 480 BCE which was aimed at bringing the Greek cities under local tyrants responsive to Persia.
Sparta and Athens were natural allies who provided support to each other - Sparta leading the Dorian bloc of independent city-states, Athens the Ionian bloc, with both interested in maintaining peace. So when a Persian expedition was sent to subdue Athens in 490 BCE after its interference in the Ionian Revolt against Persia, Athens naturally asked Sparta for support (however Athens had defeated the Persians at Marathon by the time the Spartans arrived). When Persia sent a full scale invasion in 480 BCE, the southern Greek city-states united to repel it under the leadership of Sparta with Athens providing the largest naval component. They remained friends and allies until 460 BCE, when Athens sent an army to help the Spartans put down a revolt of its serf population. During this campaign they fell out and avoided each other. After the Persians agreed to peace the Athenians turned the Delian League into an empire of its own, became over-adventurous and clashed openly with the Peloponnesian League led by Sparta, resulting in the 27-year Peloponnesian War which Athens lost.