Against the Persian invasion.
Persian
Sink or swim - either stop the incessant warfare between each other and unite against the Persians ally and fight, or surrender. Some city-states fought in alliance, some joined the Persian side.
I think it unite in 1932
It was in their interests to join with the other Greek city-states in a coalition to defend their mutual interests and cities.
They united 180 Greek city-states into several alliances, the first led by Sparta, the next led by Athens.
He provided them a share in the spoils of conquest of the Persian Empire using Greek city soldiers, while using his influence in the Amphictyonic League to keep the Greek cities quiet.
Self defence.
The Persian Empire posed the greatest threat to Athens, particularly during the Greco-Persian Wars in the early 5th century BCE. The Persian invasion, culminating in battles such as Marathon in 490 BCE and Salamis in 480 BCE, aimed to subjugate the Greek city-states, including Athens. The Athenians, however, managed to unite with other Greek forces to repel the Persian advances, ultimately leading to the decline of Persian ambitions in the region. This conflict significantly shaped the future of Athens and its role in Greek history.
The Greek city-states paused their internal wars to unite and repel Persia. The superiority of the Greek land forces. The destruction of the Persian navy which limited Persia's ability to support and supply forces outside Asia.
Athens and Sparta temporarily united around 500 BC primarily to confront the common threat posed by the Persian Empire. The invasion of Persia, particularly during the Greco-Persian Wars, necessitated a coalition of Greek city-states to defend their autonomy and prevent conquest. This alliance, despite their differing political systems and rivalries, was essential for mobilizing resources and military strength against the formidable Persian forces. Their collaboration exemplified a rare moment of unity among the often-fractious Greek city-states.
They remained independent.