According to Guns, Germs, and Steel, why did writing arise?
The answer to this can be found in Chapter 12. There, Diamond tells us that writing arises as societies begin to become more densely populated and to have more complex social systems. This is an outcome of food production.
When societies start to farm, the come to have surplus foods and can support larger populations. This leads to the formation of things like governments and trade. Governments and merchants need to keep records of what they have. This need can lead to the development of writing.
Thus, writing arises because farming leads to bigger populations and more complex societies that need records to be kept.
Many folks think that written language began with counting token, which are common in Neolithic archaeological sites. The tokens appear to have represented various kinds and amounts of property like number of goats or baskets of corn.