You'll find the answer extensively in Ibn Khaldoun's Muqqadimah
http://www.muslimphilosophy.com/ik/Muqaddimah/