Some say the idea of the novel came to Bulgakov after he visited the office of the Bezbozhnik, a satirical atheist magazine. It was also said that the first "Black magic" performance in the novel happened on 12 June — on 12 June 1929, the first Godless people convention started in Moscow, featuring speeches by Nikolai Bukharin and Yemelyan Yaroslavsky.
There are several interpretations of the novel itself:
Response to aggressive atheistic propaganda
One interpretation of the novel is that it is Bulgakov's response to poets and writers who he saw as starting atheist propaganda in the Soviet Russia, denying Jesus Christ as a historical character, particularly, to antireligious poems of Demyan Bedny. As such the novel can be seen as a rebuke to the aggressive "godless people". It is no accident that in both Moscow and Judea part of the novel the reader can see justification of the whole devil's image. Jewish demonology characters are a deliberate retort to the denial of God in the USSR.
Bulgakov was trying to write an apologia proving the existence of the spiritual world. However, the attempt is ad absurdum – the novel shows the reality of evil and demonic powers in this world. And the resulting question is, "If those powers exist, and the world is run by Woland and his entourage, why does this world still exist?".
One of the main ideas of the book is that the source of evil is inseparable from our world as light is from the darkness. Both Satan and Jesus Christ dwell mostly inside people. Jesus was unable to see Judas' treachery, despite Pilate's hints, because he only saw good in people. He could not protect himself, because he did not know how, nor from whom.
This interpretation presumes that Bulgakov had his own vision of Tolstoy's idea of non-resistance to evil through violence, by giving this image of Yeshua.
It was noted many times in various studies that the novel abounds with Freemason symbols, often showing Freemason rituals which, as the theory implies, originate from the mystery plays of Ancient Egypt and Ancient Greece, and suggest that Bulgakov had knowledge of Freemasonry. Bulgakov may have obtained this knowledge from his father, Afanasiy Bulgakov, and his book Modern Freemasonry.