Officially the purpose of the Modern Olympics is to foster unity and shared values among the people of the world. According to the Olympic Charter:
"Olympism is a philosophy of life, exalting and combining in a balanced whole the qualities of body, will and mind. Blending sport with culture and education, Olympism seeks to create a way of life based on the joy found in effort, the educational value of good example and respect for universal fundamental ethical principles." (Olympic Charter, Fundamental Principles, paragraph 1)
More practically, the Olympics is also a huge economic endeavour which attracts enormous media attention, and (as a result) huge marketing investment from any number of corporations.
The Olympics originated in Ancient Greece and were at the most popular in the 5th century BC. They died out somewhere around 300-400 AD, but were restarted in Paris in 1896.