Ancient Biblical History Book
Okay. So 2 Samuel isn't actually a work of scholarly history. It's got biases and its own perspective, and legends and exaggeration could very well be all mixed up with it. But it's a work that allowed the people who put it together to reflect on their own history in order to understand the course that they believed God was setting for them.
So 2 Samuel is a history book in roughly the same sort of sense that Johnny Tremain is a historical novel—though it's quite possible that parts of 2 Samuel's story could've been written by people who lived in David's time and who even met and observed him directly. (The belief that the book is entirely true and divinely inspired is, of course, a personal matter for the reader.)