My interpretation of the course of events is this:
At the start of the war, the Russian army proved to be much worse than initially expected. Many experts blamed this on a) Putin purposely weakining the military to minimize the risk of a coup and b) a deeply rooted corruption. Soldiers would only report what their superiors wanted to hear, being critical would be interpreted as disloyalty and exploiting your position to enrich yourself is the custom. This meant Putin sat in an ivory tower and made his decisions on the basis of wrong information both about the state of his army as well as the situation in Ukraine.
Wagner is a very different organization. Prighozin is rather hands on and closer to the foot soldiers. They grant their officers more freedom and are less bureaucratic and thus proved to be a much bigger threat for Ukraine than the regular Russian forces. Anyway, in the end Wagner still relied on the Russian MoD and the longer the war continued, the more this did take its toll. Prighozin was probably getting increasingly tired of the incompetence he experienced first hand and that probably cost many of his soldiers' lifes and all for an overall phyrric victory in the grander scheme of things. At the beginning, this might not even been intended by the MoD but just their usual expertise in failure, especially in regards to logistics. It probably began to sink in that the war couldn't be won this way as he grew frustrated with the pointlessness and became vocal about it. This escalated into a feud with Shoigu that quickly spiralled out of control. At this point, the MoD probably intentionally held back ammunition and supplies intentionally in a display of power to show Prighozin his place only adding fuel to the fire. Putin, as he tends to do in this war, remained indecisive and an open battle for power emerged.
Prighozin could not have been the only one seeing the incompetence of the whole military apparatus and the terrible upwards flow of information (he even claimed a few times that Putin was lied to by his consultants). He was well connected in the military, so he probably knew likeminded people in high positions. And as the conflict escalated out of control, he probably began to ask himself why he should let Shoigu threaten him when he sees first hand how incompetent the Russian military is in comparison to his own forces, likely saw how amateurish the national defense was organized and how easy it would have been to capture Rostov. At some point, he realized they wanted to eliminate him and Putin didn't protect him. So he found himself backed into a corner by an incompetent military that left his forces an easy to breach path to one of their most important logistic hubs, he knew Shoigu and Putin have lost much support in the military and among officers, that important information wouldn't get to them, that he had much support among the population as Wagner were lauded as heroes, and took his chance. Not one motive but multiples ones and the most important probably being the threat for his life. Possibly he indeed was tired of Shoigu's incompetence and wanted him gone to reorganize the army.
He seemed to have judged many things much better than most of the Russian regime as they were caught completely off guard. That they took it very seriously is evidenced by Putin's and Lukashenko's evacuations. Anyway, probably a few of his deemed supporters didn't follow up or maybe when he was offered an offramp, he just took it. Better be exiled in Belarus than waiting for your inevitable assassination in Russia. His coup has now elevated him to a status in which it is hard to kill him without making him a martyr while the deal between him and Putin seems to be very basic (stop the rebellion and save your life in exchange) as both parties are still firing shots at each other. I don't think the last chapter in this has been written. Even if it would have been great for Ukraine if there had been even more turmoil, the outcome is still good. Wagner is more or less gone and the people that stand for the incompetence and corruption of state and military remain in charge. On top of it, insurgencies are only likelier now than they have been as Putin's reputation took a severe hit.