There are several reasons why Hume used the dialogue form. The first is that it was a standard type of philosophical writing, first pioneered by Plato, and subsequently used by many other philosophers. Hume would have been particularly impressed by the way Socrates engaged in rational inquiry, starting with an open mind rather than a set of dogmatic beliefs. This particular nature of the dialogue form as exploratory was especially important for Humean skepticism. Cicero's dialogue on the gods was also a model for Hume.
Next, in the period during which Hume was writing, blasphemy was illegal. Although it was widely known that Hume was an atheist, by writing this as a dialogue, in which arguments in favor of atheism and arguments that might offend Christians were voiced by characters, rather than being spoken in propria persona, Hume could maintain a fiction that this was simply an exploration of religious issues rather than an anti-religious screed.