The gulag was a system of hundreds of forced labour camps, plus transit camps and prisons, which held criminals. Increasingly gulag prisoners were political prisoners - people who were opposed to Stalin, people accused of failing to meet their work targets and peasants sent there during the collectivisation of agriculture.
From 1929-32 the numbers of people in the gulag increased greatly, coinciding with collectivisation. It is estimated that there may have been 5-7 million people in these camps at any one time. In later years the camps also held victims of Stalin’s purges, ranging from high officials to intellectuals to ordinary people, as well as World War 2 prisoners.
Gulag prisoners were a useful supply of workers for large projects in remote and inhospitable places in the USSR. For example, the Belomor Canal, which connects the White Sea with the Baltic, was almost entirely constructed by hand, using 250,000 prisoners. Prisoners also worked in mines or cut timber.
They were not paid. They were underfed, housed in poor conditions and worked long hours in a difficult climate. They could be executed if they refused to work. It is possible that around 10% of prisoners in the gulag died each year, although we cannot tell from official figures