There is nothing wrong with writing stories if you adhere to the shar‘i conditions that make it permissible to write them and publish them. These conditions include the following:
They should not contain anything that is contrary to sharee‘ah, or matters that Islam came to oppose and warn against. Such things include shirk (association of others with Allah), innovation and evil words, deeds and behavior.
They should not contain lies about historical events or real incidents. If it is a story based on imagination, then there is nothing wrong with that, as al-Hareeri did in his Maqaamaat, in which he made up a fictional character called al-Haarith ibn Hsmmaam.
Al-Hareeri said in the introduction to his Maqaamaat: I hope that I am not going to be, in what I have written, like one who is putting himself in trouble or be like losers, those who strove in misguidance in this life, thinking that they were doing well. However, there are some smart people who turn a blind eye and do not comment on my writings, and others who like me and defend me. Yet there are ignorant people who are not prominent at all, who criticise me and suggest that what I write is haraam. But anyone who examines what I have written of these Maqaamaat will realise that they are beneficial and that they tell stories about animate beings and inanimate things. No one has ever heard of anyone who rejected such stories or regarded their writers as sinners at all. If deeds are but by intentions, then what is wrong with one who writes stories, intending thereby to highlight some issues, for the purpose of promoting good morals, and his intention was never to tell lies? Isn’t he, in that case, like a teacher who teaches good manners and guides people to the straight path?
End quote from Maqaamaat al-Hareeri, p. 17, 18
Shaykh Muhammad Rasheed Rida (may Allah have mercy on him) commented by noting: He says that he never heard of anyone among the scholars of the ummah up to his time forbidding such stories which speak of animals, such as Kaleelah wa Dimnah, and so on, because the intention behind them was to exhort and teach something good. And we have never heard of any of the scholars after his time saying that it is haraam to read his Maqaamaat. But some popular figures came up with this view and had the audacity to declare haraam that which Allah and His Messenger did not prohibit, and which none of the scholars of Islam declared to be haraam.
End quote from Majallat al-Minaar, 14/828-830, in a fatwa entitled Tamtheel al-Waqaa’i‘ at-Taareekhiyyah wa’l-Khayaaliyyah li’l-I‘tibaar.
They should have sublime aims and great meanings.
Shaykh Muhammad ibn Saalih al-‘Uthaymeen (may Allah have mercy on him) was asked: Some literary authors write stories that teach moral lessons in a very attractive style, which have a great impact on readers’ hearts, but it is all imaginary. What is the ruling on that?
He (may Allah have mercy on him) replied:
There is nothing wrong with that. There is nothing wrong with that if it deals with spiritual or moral or social problems, because there is nothing wrong with giving likenesses by telling fictional stories. In fact some of the scholars have stated that some of the likenesses given in the Holy Qur’an did not refer to real events; rather Allah gave these as examples (to teach a lesson), such as when He, may He be exalted, said (interpretation of the meaning):
“And Allah puts forward (another) example of two men, one of them dumb, who has no power over anything (disbeliever), and he is a burden to his master, whichever way he directs him, he brings no good. Is such a man equal to one (believer in the Islamic Monotheism) who commands justice, and is himself on a Straight Path?”
So I do not think that there is anything wrong with that, because the purpose is to warn others. But if it so happens that a person has knowledge of what is in the Qur’an and Sunnah, then he quotes verses in his writings that deal with problems, and he explains them and gives likenesses for them, this is something good. The same applies to quoting some hadeeths and explaining them and giving likenesses for them. This is undoubtedly good.
End quote from Fataawa ‘ala ad-Darb, tape no. 358
See also the answer to question no. 4505
In the answer to question no. 159960 you will find a detailed fatwa from Shaykh al-‘Uthaymeen, in which it says that it is permissible to earn an income from writing such stories, if they are worldly stories.
We do not think that it makes a difference whether the stories from which you earn an income are worldly or religious. What has been said about it being permissible to write stories and earn income from them may be said about writing articles and earning income from that.
We ask Allah to guide your pen and to benefit the Muslims through you.
And Allah knows best.