According to Hellenic mythology, the Olympic Games were founded by Herakles. It happened after he captured the Cretan Bull, the very same bull that got Pasiphaê, wife of Minos, pregnant with the Minotaur. There is an extended break between the completion of this labour and the start of the next, during which the Olympics came to be.

After capturing the bull, Herakles took some time to unwind, feast, and thank the Gods for all he had achieved so far. Chief amongst his accomplishments in his time off time period is the founding of the Olympic Games, which even Pausanias attributed to Herakles in the mythological retelling of the practice. He writes in his 'Description of Greece':

"Heracles of Ida, therefore, has the reputation of being the first to have held, on the occasion I mentioned, the games, and to have called them Olympic. So he established the custom of holding them every fifth year, because he and his brothers were five in number." [5.7.9]

Corroborating accounts come from, for example, Diodorus Siculus who writes:

"After the performance of this Labour Heracles established the Olympic Games, having selected for so great a festival the most beautiful of places, which was the plain lying along the banks of the Alpheius river, where he dedicated these Games to Zeus the Father. And he stipulated that he prize in them should be only a crown, since he himself had conferred benefits upon the race of men without receiving any monetary reward.

All the contests were won by himself without opposition by anyone else, since no one was bold enough to contend with him because of his exceeding prowess. And yet the contests are very different one from another, since it is hard for a boxer or one who enters for the “Pankration” to defeat a man who runs the “stadion,” and equally difficult for the man who wins first place in the light contests to wear down those who excel in the heavy. Consequently it was fitting that of all Games the Olympic should be the one most honoured, since they were instituted by a noble man." [4.14.1 - 4.14.2]

That said, of course there are a great many non-mythological accounts of how the Olympics came to be. My favorite, perhaps, is from Diodorus Siculus again, who writes a beautiful line between myth and his reality, speaking of the five Daktyloi, daimones who were appointed by Rhea to guard the infant God Zeus in a cave on Mount Ida in Krete and eventually established the Olympic Games in the age of Kronos. One of them was called Hēraklēs as well:

"Also the greater number of the gods who, because of their benefactions to all men alike, have been accorded immortal honours, had their origin, so their myths relate, in their land; and of the tradition regarding these gods we shall now give a summary account, following the most reputable writers who have recorded the affairs of Crete.

The first of these gods of whom tradition has left a record made their home in Crete about Mt. Idê and were called Idaean Dactyli. These, according to one tradition, were one hundred in number, but others say that there were only ten to receive this name, corresponding in number to the fingers (dactyli) of the hands.

But some historians, and Ephorus is one of them, record that the Idaean Dactyli were in fact born on the Mt. Idê which is in Phrygia and passed over to Europe together with Mygdon; and since they were wizards, they practised charms and initiatory rites and mysteries, and in the course of a sojourn in Samothrace they amazed the natives of that island not a little by their skill in such matters. And it was at this time, we are further told, that Orpheus, who was endowed with an exceptional gift of poesy and song, also became a pupil of theirs, and he was subsequently the first to introduce initiatory rites and mysteries to the Greeks.

However this may be, the Idaean Dactyli of Crete, so tradition tells us, discovered both the use of fire and what the metals copper and iron are, as well as the means of working them, this being done in the territory of the city of Aptera at Berecynthus, as it is called; and since they were looked upon as the originators of great blessings for the race of men, they were accorded immortal honours. And writers tell us that one of them was named Heracles, and excelling as he did in fame, he established the Olympic Games, and that the men of a later period thought, because the name was the same, that it was the son of Alcmenê who had founded the institution of the Olympic Games." [5.64.2 - 5.64.6]

No one knows who actually founded the first Olympics, so I'll take the mythical explanation of a hero named Herakles, who founded the Games to honor the Gods and receive blessings upon himself so he would be able to complete the coming labors.