The origin of the pagoda can be traced to the stupa (3rd century BC).The stupa, a dome shaped monument, was used as a commemorative monument associated with storing sacred relics. The stupa emerged as a distinctive style of newari architecture and was adopted in Southeast and East Asia. Nepali architect Araniko visited China and shared his skills to build stupa building in China. where it became prominent as a Buddhist monument used for enshrining sacred relics. In East Asia, the architecture of Chinese towers and Chinese pavilions blended into pagoda architecture, eventually also spreading to Southeast Asia. The pagoda's original purpose was to house relics and sacred writings. This purpose was popularized due to the efforts of Buddhist missionaries, pilgrims, rulers, and ordinary devotees to seek out, distribute, and extol Buddhist relics.
Source WikiPedia