Remark
Andalusia is a province in southern Spain. It was conquered by the Arabs in 711 before being taken over by the Catholic Monarchs in 1492.
Ibn Khaldûn comes from a family of scholars and high officials.
Ibn Khaldûn tried to determine laws that repeat themselves in political structures. He expressed his ideas in his work, the Muqaddima or "Book of Examples".
For him, there are two ways of life in society:
“Bedouinity”: that is to say the nomadic way of life of the Bedouins. This corresponds to all people having a difficult existence (life in the desert or in the steppes). In this way of life, men are equal because the living conditions are difficult, it is necessary to be united.
Sedentariness: it is a way of life in which men are "disarmed". They are ruled by a state that levies a tax on the population in order to maintain an army.
These two ways of life are bound to meet. However, for Ibn Khaldûn, the peoples are constituted, are created, in the conquest of the State. The Khaldûnian theory implies a perpetual repetition:
Bedouinism unites to form a wave that sweeps away everything in its path and overthrows the state. A sedentary lifestyle can do nothing in the face of the solidarity and violence that unite the nomadic clans
the Bedouins become the masters of the city. They settle down, create a dynasty and settle down
for fear of being overthrown in turn, the dominant clan disarms its own troops. The state is exhausting its own resources to stay in power (paying mercenaries, raising more taxes, etc.)
the State, which had become weak, was in turn overthrown by a new tribal groundswell.
Because of the limited format here I have been obliged to give only a cursory summary of Ibn Khaldun's theory. therefore I advise you to read his book