The purpose of dialogue is to advance the plot, communicate information, develop character voice, illuminate the theme, provide conflict, and/or change the direction of the plot.
Dialogue can be used in a variety of ways to accomplish these goals.

Be evasive
Direct Q&A between characters can get boring very quickly. Sidestep answers, be roundabout with explanations, create mystery, and make the reader question what’s being said. Dialogue is a great opportunity for teasing out information and leading the reader toward an idea without expressing it directly.
Use silence
When a character needs a moment to consider what they’ve been told, use exposition to allow for internal thought, emotion, or observation. This is a great opportunity to add sensory details and flesh out the scene. Study how people talk and use natural pauses as opportunities to expand on what’s being discussed.
Make it a confrontation
Confrontational dialogue exchanges can convey a great deal of information without being lengthy. These types of exchanges give hints and lead the reader toward ideas and conclusions rather than openly telling them. Take this excerpt as an example of confrontation in dialogue:
“I know who you are,” Charles said.
“You know nothing,” John said.
“You’re that doctor.”
“If you don’t mind, I—”
“From Hopkins. You killed that woman because you were soused. Yeah, that’s it.”
This example gives the reader information about John’s past and the fact that many people are aware of what he did. It also gives a glimpse into his personality and how he feels about the situation and being known mainly for his mistake. The reader gets a few specific details about the event, but not enough to know the whole story. This exchange builds conflict and reveals important information.

Polish later
Just like it’s often a challenge to come up with the right response on the spot when in a conversation, getting the responses right in dialogue can also take time. Don’t be afraid to write out the dialogue to get the basic structure down, but come back later to fine tune and tweak.
Dialogue resources
If you struggle with punctuating dialogue properly, this is a great resource!
Studying dialogue from movies can also help writers improve their dialogue and use is more purposefully. Check out this fun link of great dialogue scenes from movies!