It should not be used for mundane greetings, conversations about the weather (unless it concerns character development), or random things which do not influence the plot or reveal the personality of the speakers (a conversation with a cashier, that never appears again, about the rising prices of gas should not be included unless your novel happens to concern that, for example). What it should be, however, is realistic for the character that is speaking. It should seem like something someone would actually say to the person they are talking to; it shouldn't reference the past too much (if you're using it for exposition purposes), if at all, and it should flow normally. As an example, whenever your tell a joke to your friends about a party they were all there for, would you go in depth about the party? No. You would just assume that they would understand - it's the same with your characters. When they are talking to someone that they know, they assume certain things are known.
The other problem is with flow; what I mean by that is how things are revealed within dialogue. All too often I'll read a novel that has a character simply telling another character outright what the problem is and how they feel about it. Only the bluntest of characters will do that (or characters within a dire, urgent situation) Think about it for a moment; when you want something, or have a problem, you're unlikely to just go up to the another person Dialogue also has to fit the mood of the scene; eloquence is not usually present when monsters are attacking the city, nor is extreme formality when the speaker is around friends. Anything that anybody says is driven by some emotion, some motivation; it is what shape their words, what volume they speak in, how they approach a question. If the motivation is not present in dialogue then there's something wrong.
Here's an example of some bad dialogue, to show some of the main problems mentioned here:
"Nheim Enther, will you go to war with us, to fight against the Misery-lord, the remaining god? After that will be able to live in without his judgement." He queried.
"No, I won't." She said, looking away.
"Why not? You have seen the conditions of the city, haven't you? It's outside everyday." He said, disbelievingly.
"I can't trust you."
"You sabotaged those trials. It wasn't a good thing to do." She said.
The first problem is that the emotion is the scene is barely there; the first character is asking a friend to help them start a war, but he hardly seems interested in it and divulges too much detail that the woman already knows. For the woman, she seems coldly logical and childlike in her moral stance, speaking in simple sentences and vague responses. This moves the plot forward, but in a way that seems forced, as though this dialogue has to be there, but the authour sure isn't going to take time making it good.
To fix it, rewording is required, as well as putting more information into the dialogue tags without dragging it down.
"T - Nheim Enther," Her title was unfamiliar on his tongue. "The Amourci requested that I start a war - we wonder if you will be on our side."
She should look surprised, but instead she looked as though she had been expecting this conversation to come.
"I won't fight with you. I'm still loyal," She said, taunting, bitter.
"Galen, you can't trust him. I know that, far better than anyone-"
"I've told you where I stand."
"You've seen the condition of the Amourci, the Ventri - Cabriel, itself, " His voice rose.
"They did not see, they did not trust."
"Please, Tesian, we need your leadership," He made one last attempt, pleading.
"I can no longer trust your judgement." It was said in an abrasive whisper. Aureliusz bristled.
"In truth, I don't think I ever should have."
"What do you mean by that?" He was deadpan, his tone a reflection of his mind.
"Don't play innocent, Aureliusz. I know you were never that," She laughed without mirth. "At least, I know now."He gestured sharply for her to explain, the tendrils of self-loathing feeding this destructive activity. Her cup was slammed on the counter.
"I know what you did, on the trials - I heard about how you prevented that envoy from being tried, the numerous others that you sabotaged. Who knows how many murderers went loose because of you!"
While this isn't perfect, it's better than the first; the emotion of both characters is better reflected in there words, and, while past history is referenced, it is not outright stated. This slice of dialogue now achieves two things; it adds more conflict to the plot and reveals the personality of the characters. It is now (hopefully) more realistic and actually interesting to the people reading it (within context).
A Helpful Link:
Examples of Bad Dialogue