People write books for different reasons. For memoirs, it could be that a certain experience had such a profound impact on one’s life that it naturally overflows into a need to pour one’s heart out. For a biography, it is often that a writer feels that a certain personality was of such significance to society and therefore there is a need to immortalise their words and deeds for future generations to benefit from.
For the autobiography, where one writes their own story, of course with the help of an editorial team, in most cases it is the need to document family or political histories so that others can glean lessons from their experiences and get a clear understanding of the journey their family, community or country has travelled, illuminating the events and realities that brought them thus far.