The Greeks simply wouldn't accept the idea of being invaded by another country and they fought until they won. Another factor was that by uniting the city-states, particularly the Spartans and Athenians, it created a skilled, well balanced army that was able to defeat the Persians despite their numbers.