According to Records of the Grand Historian, Qin Shi Huang ordered construction of his mausoleum to begin when he took the throne of the Qin State in 246 BC. The role of the Terracotta Army was to "guard" the entire mausoleum and Qin Shi Huang believed that the army could protect him in the afterlife.
hope this helps :)