Literature during the Civil War can be classified as belonging to the Realist movement. Realist literature presents the world in a realistic way -- ensuring that this moment in time will not be forgotten.
Much of this literature (for example, the work of Stephen Crane, many diaries and letters, and numerous slave narratives written during this time) presented the world as it truly was. Crane's The Red Badge of Courage is noteworthy for the realistic way it presented Civil War battles.
In this way, these works preserved history, so that it could not be forgotten. If it is not forgotten, it is harder to repeat it.