Gram, Jens, active 1737-1787, Historiographer Royal of Denmark