In principle, it is permissible to write a novel so long as the narrative is based on a known event. It should not be a mere fantasy.
If the material does not have a well-established root or history and it is merely a tale, it must be beneficial and portraying positive messages and guidance.
If one writes an account of a known event, it will be disliked to add or delete occurrences to the episode.
With regards to the income accrued from such a profession, it will be Halāl if the written novel is of a permissible nature. If the novel is of a disliked nature, the subsequent income originating from the proceeds of selling such a book will also be disliked.
And Allah Ta’ālā Knows Best
(It is the answer of a question by Mufti Faraz al-Mahmudi)