Shri Chitragupt Ji is divine incarnation in human form called Kayastha since he is the only creation of Lord Bramha, created in entirety [KAYA] from the lords body, unlike the other 16 sons who were created only from various parts of the body. Shri Chitragupt Ji (& hence the Kayastha's) were accorded a dual caste status, namely KSHATRITYA [Warrior] and BRAHMIN [The Learned]
Hindu Mythology is based on a multiple phase life cycle involving re-birth. It is believed that those who do not attain a balance between their good-deeds and misdoing, have to attain re-birth in any living form, to complete the LIFE CYCLE.
The primary duty awarded to Shri Chitragupt Ji was to create LOG of the lives of all living beings, judge their lives based on good-deeds and misdoing, and s death, whether they will attain NIRVANA [Completion of their LIFE CYCLE & redemption from all worldly troubles] or receive punishment for their misdoing in another life form, till they attain NIRVANA. He was asked by Brahma to perform his duties of keeping an account of every person good and bad deeds in the offices of Dharma Raj, supposed to be situated in 'Yampuri'.