That is an interesting question. There can be many reasons, but one of the common ones are nasal allergies. The phelgm from the nose flows down to the throat when you sleep.
The next one is acid reflux from the stomach. The stomach acid comes up through the food pipe and becomes phelgm in the throat. If it really is bothering you a lot, you should check it out with your GP.