The wall was built by peasants, slaves, criminals, and other people that the emperor decided to punish. Soldiers were involved in building the wall and in managing the workers as well.
It is estimated that millions of people worked on the wall over the course of over 1000 years. Some scientists think that up to 1 million people died while building the wall. People building the wall were not treated very well. Many people were just buried under the wall when they died.
The wall was built to help keep out northern invaders like the Mongols. Smaller walls had been built over the years, but the first Emperor of China, Qin Shi Huang, decided that he wanted a single giant wall to protect his northern borders. He ordered that a single strong wall be built with thousands of lookout towers where soldiers could guard and protect his empire.