There are few historical entities that engender as much debate, confusion, and controversy as the history and reality of Shaolin. Though the Shaolin order has existed for millenia, its martial arts roots date to about 495 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 an impression of his own image into one side of the cave with his constant gaze.
When Tamo joined the monks, he observed that they were in poor physical condition. 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 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.
It is hard to say just when the exercises became "martial arts". The Shaolin temple was in a secluded area where bandits would have traveled and wild animals were an occasional problem, so the martial side of the temple probably started out to fulfill self-defense needs. After a while, these movements were codified into a system of self-defense.
As time went on, this Buddhist sect became more and more distinct because of the martial arts being studied. This is not to say that Tamo "invented" martial arts. Martial arts had existed in China for centuries. But within confines of the temple, it was possible to develop and organize these martial arts into the new and different styles that would become distinctly Shaolin.
The Shaolin philosophy is one that started from Buddhism and later adopted many Taoist principles to become a new sect. Thus even though a temple may have been Taoist or Buddhist at first, once it became Shaolin, it was a member of a new order, an amalgamation of the prevailing Chinese philosophies of the time.
Other temples sprung from Henan. This happened because the original temple would suffer repeated attacks and periods of inactivity as the reigning Imperial and regional leaders feared the martial powers of the not-always unaligned monks. Refugee Shaolin practitioners would leave the temple to teach privately (in Pai) or at other Buddhist or Taoist temples. In rare cases, a new Shaolin Temple would be erected (Fukien, Kwangtung) or converted from a pre-existing temple (Wu-Tang, O Mei Shan). Politically and militarily involved monks (such as the legendary White Eyebrow and Hung Tze Kwan) would be perpetual sources of trouble for the generally gentle aloof monks.
Because of their high level of spirituality, their extreme physical talents, and their education, becoming a Shaolin monk was a most desirable choice in life. Many parents sent their young sons to the temple in hopes of them attaining a better life by gaining admittance to the temple. However, it was not easy to become a student at the temple. The monks were very picky about who was admitted and often tested the potential students. Young boys stood at the gates for weeks, rain or shine, hoping to be selected. If they were chosen and permitted to enter the temple, they would be given chores for months before receiving any form of training. The smallest mistake could cost them everything they had worked for and they could be cast out at any time. Early training consisted of ruthless conditioning and endless stances. Once they were accepted as disciples and assigned to a master, the real training began. They received instruction in reading, writing, philosophy, and the martial arts.