Therre is this amazing political theory book called The Dictator's Handbook [1] by Bueno de Mesquita and Smith which itself is a popularized version of their Theory of Selectoriat (i am not sure if it is a cortect translation) from Mesquita's book called The Logic of Political Survival. I highly recommend it, for me it is one of the most important books I've ever read. It explains exactly what you wrote about.
CGP Grey made great recap in one of his videos [2] called Rules for Rulers.
[1]https://en.wikipedia.org/wiki/The_Dictator%27s_Handbook
[2] https://youtube.com/watch?v=rStL7niR7gs&feature=share8