I wanted to know if there are any mentions about why Allah created Jinns? Do they serve any purpose? Will they also be held accountable for their good and bad deeds? Are the rules applied to them are same as humans? Is there any book revealed for them as well?
Summary: The Jinn are a creation of Allah (SWT), and their purpose is to worship Allah. They will also be held accountable and punished or rewarded for their actions. And the Quran is a guidance for both Mankind and the Jinn.
Allah says in the Quran:
And I did not create the jinn and mankind except to worship Me. (56:51, Saheeh International)
Source for this verse: https://quran.com/51:56
This verse indicates that Allah created both the Jinn and the Mankind to worship him. And that the purpose of both of them is to worship Allah. In another verse:
And We have certainly beautified the nearest heaven with lamps [i.e., stars] and have made [from] them what is thrown at the devils and have prepared for them the punishment of the Blaze. (Saheeh International, 67:5)
Source for this verse: https://quran.com/67:5
This verse indicates that even the devils will be punished for their sins. And even the Jinns are a creation of Allah with free will, and in the Quran the Jinns said:
And among us are the righteous, and among us are [others] not so; we were [of] divided ways. (Saheeh International, 72:11)
Source for this verse: https://quran.com/72:11
This is proof that the Jinns, just like humans, have free will. And they also have the ability to make their own decisions, and among them are the righteous and the evil.
And the Quran is a guidance for both Jinn and Humans. The proof from the Quran is:
Say, [O Muḥammad], "It has been revealed to me that a group of the jinn listened and said, 'Indeed, we have heard an amazing Qur’ān [i.e., recitation]. It guides to the right course, and we have believed in it. And we will never associate with our Lord anyone. And [it teaches] that exalted is the nobleness of our Lord; He has not taken a wife or a son And that our foolish one [i.e., Iblees] has been saying about Allāh an excessive transgression. (Saheeh International, 72:1-4)
Source for this verse: https://quran.com/72/1-4
And Allah knows best.