Before Purim, someone shared a beautiful pshat with me in the name of the Chasam Sofer (I believe).
If one goes back to the root of the miracle of Purim, we can trace the beginning stage to the party of Achashverosh that is described at the beginning of the story. During that party, the king asks Vashti to appear, but she refuses. In his anger, he heeds the advice to be rid of her, lest the women in the countries of his dominion learn of her intransigence and be led to do the same to their own husbands. Vashti is removed from the scene, leaving an opening for Esther to become a key player in the miracle of Purim.
What is most interesting is that the seeds for the miracle are sown at the very moment that the Jewish people were doing the sin that created the necessity for the miracle! They had been instructed by Mordechai to refrain from partaking in the party of Achashverosh, but they did not listen to the advice of the gadol. In their minds it was more important to join the party, as loyal citizens of Persia, rather than make a scene. Their mistake led to the decree of Haman to wipe out the Jewish people.
What comes out of it is that at the time the Jews were sinning and bringing upon themselves a great calamity, Hashem was concurrently preparing the miracle of their salvation. What an amazing chessed of Hashem! When His beloved people are straying from Him, in His great love He is thinking of them and creating the potential for the miracle of their salvation.
When I heard this idea, I could only think of our people today, many of whom may be entrenched in things that would pull us away from Hashem, ח"ו. Nevertheless, Hashem is constantly looking out for our best, planting the seeds of redemption even as we do things that perhaps make us unworthy! Could there be any greater kindness?