Okay this might be long. In the Bible, God keeps talking about the Caananites, Hitites etc. all the '-ites. Well, those were actually races of giants. Now, giants were born when a demon (fallen angel) came down and married in with the mortal people(regular people), and that produced giants. Now what happens when you have all these demons marrying people? It creates an unclean line. God needed a pure line for Jesus to come through, and it wasn't going to be through lines of giants. To solve this problem, God had to wipe out all the bad races aka the giants. Now some of the giants may not have been marrying the demons and instead doing good stuff aka believing in God. Some may have been marrying the demons. So when the good ones were killed they weren't sent to hell because they weren't bad (definition: They believed in God), but they couldn't be sent to heaven just yet because they are unclean. God is waiting untill judgment day to put them somewhere. So untill then they are in a little holding place. So sometimes they do rome around aka ghosts. There will be an age God says were they will be released and they will marry in with the people on earth. I hope that answers the question. Ghosts can also be demons.