The pyramids were not built by slaves. For a long time it was believed that the pyramids were built by hundreds of thousands of slaves, who were hardly fed, beaten with whips and, of course, buried in large numbers somewhere nearby. But no mass graves have been found so far. But archaeologists have found several settlements of builders, where there were hostels, canteens, bakeries, and even breweries.
The conclusion suggests itself - the pyramids were built by free people, who, perhaps, even received payment for this (perhaps in the form of products). According to one theory, due to the climate of Egypt, where you can farm for only a few months (after the flood of the Nile), the rest of the time the population of the country could hardly find an opportunity to feed themselves.
Therefore, in order to occupy the population (primarily the male population), let them earn money and prevent possible riots, the pharaohs attracted them to the construction of the pyramids. But during periods of agricultural work, slaves may have been brought to construction sites