After The Buddha's death, his ashes are said to have been divided into eight portions. Source:Wikipedia
The cause of arising of the Buddha’s relics was from the desire of our Lord Buddha before his Parinibbāna (the Great Decease of the Buddha).
Normally, the Buddha who lived a long life to settle the Buddhist Legend, had his own relics in a piece of natural golden bar, which could not be shared among the people in their Buddha period and could not be placed anywhere. Hence the construction of the Buddhist sanctuary was required to be done in one place only. Our present Lord Buddha (Sakyamuni Buddha) considered that his teaching period was only 45 years which he thought not too much compared with the previous Buddhas. He also thought that his instructions were not expanded enough and taught to those who were not yet born on time in his legend. Anyone who received his relics for respecting would get a lot of Puñña (the accumulation of good blessing, fortune or well-being) so he wished that his relics be scattered to all directions except 7 pieces (1 frontal bone, 4 teeth and 2 collarbones).
All of the above mentioned information was presented identically such as in the Sumaṅgalavilāsinī, Paṭhama Sambodhi Kathā by the Supreme Patriarch Kromphra Paramānujitajinorasa, Mulasāsanā Scripture, Jinakalamalipakaranam by Ven. Ratanapañña Thera and Phrachaolieplok Scripture.
Source:The history of the arising of Buddha’s relics
If you want to know more depth details, Please read Maha-parinibbana Sutta: Last Days of the Buddha
Eight portions there were of the relics of him, The All-Seeing One, the greatest of men. Seven in Jambudipa are honored, and one In Ramagama, by kings of the Naga race. One tooth is honored in the Tavatimsa heaven, One in the realm of Kalinga, and one by the Naga kings. Through their brightness this bountiful earth With its most excellent gifts is endowed; For thus the relics of the All-Seeing One are best honored By those who are worthy of honor — by gods and Nagas And lords of men, yea, by the highest of mankind. Pay homage with clasped hands! For hard indeed it is Through hundreds of ages to meet with an All-Enlightened One!