I'm currently reading Fatal Decision: Anzio and the Battle for Rome by Carlo D'Este and every few pages he references official histories. Why do different governments commissions them? Who writes them? Who decides what's important?
Speaking only in the case of China (might also apply to Korea but someone more qualified will have to address that)
Why do different governments commissions them?
A very major reason for their writing has historically been for the sake of creating legitimacy for the new government. One dynasty falls to another, and now the new dynasty needs to convince the people that they have the Mandate of Heaven (天命 tianming) — true legitimacy to rule the land — and often this is done by explaining things like how the past dynasty fell due to their greed and corruption. Had the past emperor given more consideration to the people they might still be around, etc etc.
The official history is also a history, and glorifies the great battles and important events. That is to say, it's not just trying to legitimise the new government. But that's a big part of it.
Who writes them?
In the most general terms, the authors are historians who are in the good graces of the government or people who are specifically appointed to this task. For example, the History of the Ming was written in the following period, the Qing, by a group of officials commissioned by the court. The person in charge of this group, Zhāng Tíngyù (张廷玉), was someone who'd done incredibly well on the civil service exam, got a good job with the government, impressed a bunch of people and made a reputation for himself as being a good dude and a decent writer. In addition, he was trusted by the people in charge, so he was given the task of leading the compilation of the official history.
Who decides what's important?
Again in the most general terms, what's important is what serves the narrative of the new dynasty. What things show how the new government is deserving of the role? Which things might explain what wen't wrong with the previous government? What things make for good stories? What things explain the lives of major figures or detail the major events? Those things are typically what's important.
If you're interested in China's histories in particular, Wikipedia has an article on the 24 official histories and that's a good place to start.