This 8 minute scene of mostly dialogue has three main functions.
At this point in the movie, in the beginning of act three, after the previous story twists, our expectations of what is to come are already well set up. But here John Doe is very confident and repetedly emphasizes the impact of his coming act. This raises even more the audience expectation and triggers an almost unbarable curiosity for the climax. (Just imagine a hand of God breaking your DVD-player just before the end sequence and you would Never Ever get to know what happened!)
On another level the dialogue handles the theme as John Doe explains his motivation for his beastly act. We learn that his engagement is perfectly reflecting the reason of Somerset to resign. They share a dark view of the world as a place where nobody cares anymore. But, and this should really be annoying, as Somerset chooses to stand back and resign, John Doe, in his perverted way, takes action to make the world a better place.
Finally, the escalating conflict between Mills and John Doe, that ends with John Doe humiliating Mills, is needed to emotionally set up Mills for the actions of the climax.