Writing good dialogue is more than putting words on a page encased in speech marks followed by tags. It’s about tone, atmosphere, and style.
You can only put these three elements together if you know your viewpoint character inside and out: who are they? Where do they come from? What’s their background? How do they talk?
If you understand your characters, you can make them believable. You can show how they’d react in any situation, such as meeting somebody for the first time, interacting with a friend, or weaving through traffic at high speed. You can show their normal state of mind and mood through your narrative and how it changes with different challenges.
How does this relate to dialogue?
Tone, atmosphere, and style.
By understanding your viewpoint character, you can control the tone of narrative through diction – word choices – what words would they use? By their choice of words, you can show accent and mood. You control the atmosphere of a scene through effective use of syntax – word order and sentence construction: how would they say it? What’s their natural dialect? You control both these elements by effective use of the third – style.
Whichever convention of style you adhere to, Chicago Manual of Style, New Hart’s Rules, or your own house style, etc. by using it you can control how a reader feels while reading a scene; you can play with their emotions through the words and actions of your characters.
Good dialogue can bring your character’s to life: bad dialogue can be the kiss of death for your story.