The Ramchal addresses that question at length in Derech Hashem. To quote a little from the beginning:
Part Three, On Divine Inspiration and Prophecy
1Regarding holy spirit (divine inspiration): Behold that the Creator, may He be blessed, implanted into man's nature that he can learn, understand and be enlightened by observing [various] entities and their characteristics. And from what is revealed in front of him, he can contemplate and deduce that which is not revealed - until he grasps it and masters it. And this is the natural way of comprehension. However He also decreed that there be another type of comprehension that is much superior to this. And that is the comprehension that is [divinely] inspired: That is that an influence from Him, may He blessed, comes to one through certain means that He set up for this. And when this influence reaches his intellect, clear knowledge of a certain thing is implanted in it. So he will know the thing completely, [along] with its causes and its outcomes - everything according to its level. And this matter is called holy spirit.
2Things grasped by holy spirit: And note that in this way, one may grasp matters that are within the category of natural comprehension - just with greater clarity, as we have written. But he can also grasp matters that are not in the category of what can be grasped by natural comprehension. Included in those things are future events and hidden matters.
3Sparking of holy spirit in its absence: However, there are different levels found in the thing - in the matter of the power of the flow of the influences, in the way that it comes to a man and in the nature of the things that are revealed and made known through it. Yet in all of them, the influence exists in such a way that the one influenced is fully aware of it. However it can also happen that an influence will flow into the heart of a man, such that he will master the content of a certain matter but will not feel from it that he is influenced, but rather feel like someone who had a thought occur to him. And sometimes - in the words of the Sages, may their memory be blessed - this is [also] called the holy spirit, or hidden influence, by way of extension. Nevertheless true holy spirit is clearly recognizable and felt by its holder.
4Regarding prophecy: Yet there is another level above all of this, and that is prophecy. And its content is that a man reaches to connect with the Creator, may His name be blessed, and truly cleave to Him in such a way that he feels the cleaving, and grasps that to which he is cleaving - meaning to His glory, may He be blessed - according to the way we shall explain below. And the thing is clear and perceived by him without any doubt, in the same way that he would have no doubts about something physical that he perceives with his senses. Note that the essence of prophecy is the attainment of this cleaving and connection while he is still alive, which is certainly a great perfection. However accompanying this is [also] information and understandings. For through this, he is truly able to grasp very great and true matters from His hidden secrets, may He be blessed. And he grasps them with clarity through the path of influenced understanding that we mentioned - with greater power than someone who is in possession of the holy spirit, as we will still discuss with God's help.