The Shaolin order dates to about 540 A.D., when an Indian Buddhist priest named Bodhidharma (Tamo in Chinese), traveled to China to see the Emperor. At that time, the Emperor had started local Buddhist monks translating Buddhist texts from Sanskrit to Chinese. The intent was to allow the general populace the ability to practice this religion.
This was a noble project, but when the Emperor believed this to be his path to Nirvana, Tamo disagreed. Tamo's view on Buddhism was that you could not achieve your goal just through good actions performed by others in your name. At this point the Emperor and Tamo parted ways and Tamo traveled to the nearby Buddhist temple to meet with the monks who were translating these Buddhist texts.
The temple had been built years before in the remains of a forest that had been cleared or burned down. At the time of the building of the temple, the emperor's gardeners had also planted new trees. Thus the temple was named "young (or new) forest", (Shaolin in Mandarin, Sil Lum in Cantonese).
When Tamo arrived at the temple, he was refused admittance, probably being thought of as an upstart or foreign meddler by the head abbot (Fang Chang). Rejected by the monks, Tamo went to a nearby cave and meditated until the monks recognized his religious prowess and admitted him. Legend has it that he bored a hole through one side of the cave with his constant gaze; in fact, the accomplishment that earned his recognition is lost to history.
When Tamo joined the monks, he observed that they were not in good physical condition. Most of their routine paralleled that of the Irish monks of the Middle Ages, who spent hours each day hunched over tables where they transcribed handwritten texts. Consequently, the Shaolin monks lacked the physical and mental stamina needed to perform even the most basic of Buddhist meditation practices. Tamo countered this weakness by teaching them moving exercises, designed to both enhance chi flow and build strength. These sets, modified from Indian yogas (mainly hatha, and raja) were based on the movements of the 18 main animals in Indo-Chinese iconography (e.g., tiger, deer, leopard, cobra, snake, dragon, etc.), were the beginnings of Shaolin Kung Fu.