First, the history stored locally by the client can be deleted or altered by the user, so you should keep that in mind while using it as an evidence in court
To have history logs on the server there are two ways. One is with the Monitoring Service plugin, which you will find in the Plugins menu. But it is not developed or maintained actively and sometimes stops working out of nowhere, so i can't suggest it 100%. Use it at your own risk. Also it will make you database grow huge over the time.
Another option is to turn on Message Audit Policy in the Server Settings (Admin Console). It will store conversations in logs (in xml format). I like that you can set how big the logs can be and how long should they be stored. Also it is good that they are not in the database. BUT, these logs are not easily readable. You can try audit log reader provided by a community user here https://community.igniterealtime.org/docs/DOC-1874