"Beelzebul! He casts out demons by Beelzebul!" Such was the vicious response of the Pharisees after Jesus healed a demon-possessed man. Jesus pointed out that their charge was absurd and illogical, and then accused them of having committed the unpardonable sin (Matt. 12:22–32). He said that the Ninevites (who repented at Jonah's preaching) and the queen of the South (who came to hear the wisdom of Solomon) would rise up at the judgment against "this generation" (vv. 41–42). One greater than Jonah and Solomon was in their midst, and they rejected Him.
Jesus then spoke of an unclean spirit's going out of a person, wandering, and eventually reentering that person with seven other spirits more evil than itself (vv. 43–45):
When the unclean spirit has gone out of a person, it passes through waterless places seeking rest, but finds none. Then it says, "I will return to my house from which I came." And when it comes, it finds the house empty, swept, and put in order. Then it goes and brings with it seven other spirits more evil than itself, and they enter and dwell there, and the last state of that person is worse than the first. So also will it be with this evil generation.
The context of the passage is like a series of ever-widening concentric circles. The narrower context focuses on the Pharisees' hostility to Jesus and His condemnation of them. The wider context stretches back to the ministry of John the Baptist. At John's preaching, many people (outwardly at least) turned to a better lifestyle (3:5–6). Jesus' ministry also attracted great interest initially. At one point, the people were ready to do whatever was necessary to make Him their king (John 6:15). But the next day, many of His "disciples" turned back and no longer walked with Him (6:59–66).
Thus, an unclean, demonic spirit can be said to depart from a person when that person decides to make a change for the better. He has turned over a new leaf by self-effort and things are seemingly better. But in reality, a spiritual vacuum has been created. As the Reformation Study Bible states, "Unless God's Spirit takes up residence (Rom. 8:9), a person purged by self-denial becomes vulnerable to reinfestation by graver evils such as pride, hypocrisy, and contempt for others." Thus, this person's last state will be much worse than the first.
Jesus concludes, "So also will it be with this evil generation." Jesus described that generation (typified by the Pharisees) as fickle, wicked, and adulterous because of its failure to receive Him for who He is—the heaven-sent Savior. So also will it be with every generation (and every individual) that fails to recognize and embrace Him.