What does Mark 5:8 mean?Ancient literature was mostly concerned with providing important details, not describing a story in a direct narrative. In that style, Mark doesn't necessarily give complete conversations. He concentrates on the action and records dialogue when it applies to the topic at hand. So, this story of Jesus and the legion of demons is not kept in a neat-and-clean order. It's riddled with pauses for back-story and asides, as in this case. The demons' attempts to keep Jesus from hurting them (Mark 5:7) was actually given in response to His command to leave.
An "unclean spirit" is a demon—an angel that followed Satan in his rebellion against God. "Unclean spirit" is taken from two Greek root words: akarthartos, which refers to something that is ethically wrong and not set aside for holy use, and pneuma, which can mean breath or wind, but here means a being with thoughts and desires who does not have a physical body. Neither demons nor angels naturally have a solid form, although God may allow them to use one for His purposes.
In some cases, Jesus' commands to demons are immediately obeyed (Mark 1:25–26). In others, it takes more effort. The disciples, who had seen great success in expelling demons, cannot free the young boy described in Mark 9:17–29. When Jesus arrives, He explains how "this kind cannot be driven out by anything but prayer." In Daniel 10:10–14, an angel comes to Daniel, explaining that he did not respond to Daniel's questions right away because he was delayed by the demon that had authority over Persia. A stronger angel, Michael, had to fight off the demon so the messenger could get through. Although we're not told a lot about demons in the Bible, apparently there are some that are more powerful than others.
We often want God to answer our prayers instantly and completely, but sometimes the work takes time and effort. God often works with us through the context of our own story. This is a good example. If the legion of demons had immediately fled, the pigs wouldn't have drowned, the herders wouldn't have told the nearby people of Jesus' power, and it's very possible that Jesus' next visit to Decapolis wouldn't have been as successful (Mark 7:31–37).