Individuals in a race compete with another or others to see who is fastest. But when the race competition was invented? It is reported that races were popular in the ancient Olympic games: (see https://www.olympic.org/ancient-olympic-games/the-sports-events). Is this the first recorded example of a race competition in human history? Or there are older examples?
The earliest evidence of a footrace may well be from Sumer around 2000 BC. You may also want to consider the Sed festival in Egypt which dates back to before 3000 BC and which involved the pharaoh having to complete a race after ruling for 30 years, this in order to prove his fitness to continue to rule.
Sumerian documents also record that some of the general population participated in organized running events. One month was known as the “footrace month,” during which there was an annual run as part of the festivities in the city of Umma, located between Nippur and Ur.
Source: Nigel Crowther, 'Sport in Ancient Times' (2007)
Specific examples are given in the article Running Phenomena in Ancient Sumer by Deane Anderson Lamont in the Journal of Sport History (vol 22, No. 3, 1995). In the city of Umma, two tablets have been found dating to the reign of Shu-Suen (about 2038 to 2030 BC). Both of them list provisions for 'city race-making' during the 8th month in Sumer (15th Oct to 15th Nov).
Lamont also cites a reference to "foot-race month" in a legal document dating to the Babylonian period from around 1800 BC.
The earliest mention of a run is recorded in a royal hymn dating to c. 2088 BC, and concerns a race against time by King Shulgi of Ur himself:
King Shulgi planned to appear at two far-distant festival locations (Nippur and Ur) in order to be seen in celebration with his subjects at each site. He was to celebrate the eshesh feasts in the important cities on the "same day"
Below is an excerpt from "Sulgi the King of the Road" (as labelled by Samuel Kramer):
Like a wild ass I galloped, With my heart full of joy, I ran onward. Racing like a solitary wild-donkey, (Before) Utu set his face toward his 'house', I traversed a distance of fifteen 'miles'. My sag-ur-sag priests gazed at me (with astonishment): In Nippur and Ur, in one day, I celebrated their e s e s-festival!
Source: Jacob Klein, 'The Royal Hymns of Shulgi King of Or: Man's Quest for Immortal Fame' (Transactions on the American Philosophical Society, vol. 71, part 7, 1981)
It is certainly possible that the king could have attended both events if he was in a "highly trained physiological state". However, completing the round trip (over 200 miles) in 24 hours seems less plausible given that the current world record for the longest distance run in a day is 188.59 miles (set in 1997).
This was not a race in the sense you may interested in as it had only one participant (the pharaoh) and there's no clear time limit; the challenge was to complete the race distance. In the article The Sed-festival (Heb Sed) Renewal of the kings' Reign, Dr. Sameh M. Arab of Alexandria University writes:
The Sed festival (Heb Sed), named after the jackal god "Sed", was the most important celebration of kingship in ancient Egypt. Its origin rooted in the pre-dynastic times (before 3150 BC) and lasted until the Ptolemaic Period, celebrating the continued rule of the pharaoh.
The festival aimed to renew the reigning king's power that had become depleted over time, endangering the continued existence of the state. This was a replacement of the more ancient ritual of killing the king who became unable to continue his reign effectively because of ageing.
Thus, originally, the ruler was effectively running for his throne and even his life, though it is clear that later on it became much more of a ritual rather than an actual test of the ruler's physical capabilities.
"Ebony label depicting the pharaoh Den, found in his tomb in Abydos, circa 3000 BC. Top register depicts the king running in his Heb Sed festival as well as seated on a throne. Lower register depicts the destruction of enemy strongholds and the taking of captives." Attribution: British Museum [CC BY 2.5 (https://creativecommons.org/licenses/by/2.5)]. Source.