Who was allowed to participate in the ancient Greece Olympics?

Only those men who could prove that they were Greek. Unfortunately for us, ethnicity was not the same then as we see it now. By this I mean that everyone from Herodotus to Plutarch had a different interpretation on who was/was not Greek and why. In many ways, being Greek was more of a social identity than it necessarily was a racial/ethnic one.
Alexander the Great is a perfect example of this ambiguity: he competed in the Olympic games towards the end of the Classical period, however there was debate surrounding the legitimacy of his claim because he displayed characteristics that were considered both Greek and barbarian depending on the author. He was also from Macedonia which was a region considered only semi-Greek by most of the prominent poleis (city-states).

Hope that helps!