Here on the stack exchange we talk about dragons... a lot. We have discussed all the factors that would allow dragons to exist and yet, there is a question we have not asked. What evolutionary pressure would lead to realistic dragons?
A proto-dragon will have to deal with escaping enemies and acquiring food just like every other animal. Below is a rough process for how a dragon would evolve.
Before we get to dragons, let's consider the bat. We start with a quadrupedal animal then end up with two wings and two legs. At every stage, the animal is function and slightly higher performant than the previous generation.
So let's look at the Welsh dragon (the image chosen because it forms a basic body plan for a dragon. Of course, there are a thousand different variations on dragons. I've chosen a very basic variety.)
Starting with a basic six legged creature that lives in the trees. Getting from one tree to another is achieved by jumping and those creatures with increased surface area can jump/glide further, thus giving them a survival advantage. As time goes on, the skin between the middle leg and torso stretches to encompass an ever greater area (till the bones in the middle arms become to weak and break frequently enough to cause that sub-species to die off.) At the same time, the tail extends for balance and offers another place to increase surface area.
Claws on the hands and feet offer considerable grip on tree bark and also help with predation of smaller animals or insects. Secondly, being a predator means you only have to eat a few meals a week to get enough energy instead of munching on plants all day like an herbivore.
Scales could evolve from proto-feathers that consolidate to form protective armor during mating rituals. If there are other large predators, these scales will help there too.
After dragons achieve true flight, they can further differentiate to fill different ecological niches. Some will get huge, others will stay smaller.
I've got no answer for how dragons would evolve fire. Maybe I'll come up with something later.
Well, this is all dependent on what a "realistic" dragon is. It sounds like you are referring to some other Q&A on the SE. I am going to base my answer around a dragon being an extremely large lizard that breathes fire. I suppose I might want to consider wings as well, as that is a common things dragons are depicted with.
So how can we explain these evolutionary traits? With SCIENCE!
How do we get an extremely large lizard? Well, thats easy. A predator's size is determined by the prey they eat. Small lizards eat bugs. Medium size lizards eat small mammals. Large lizards, like crocodiles and komodo dragons, eat buffalo. As their plant eating prey grow larger, so do their predators. And we know from dinosaurs, land predators can get very large.
Now on to breathing fire, what would cause that to evolve? Again, thats an easy one. What other reptile spits something out of its mouth? If you guessed a spitting cobra, you were right! Why do venomous snakes use venom? Many reasons, but often to incapacitate their prey and defend themselves. BTW, this is a great documentary on the evolution of venom. A chemical based fire would evolve in the exact same way, for the same reason.
The last evolutionary trait is wings. That one is too obvious to go into.
I think one of the best evolutionary incentives for dragon development would have been competition with other dragons. In a dragon's case, it's not so much a fight against prey as it is a fight against other predators; most likely the only cause of a dragon's death before humans would be because another dragon stole their food (or killed them for it). This competition could lead to bigger dragons who can bully the smaller ones, or flying dragons that can get to the prey faster. Fire breath may have been an early anti-dragon development, for which fire-proofing was evolved (thus, dragons aren't fireproof to defend against their own fire, but to defend against the fire of competitors).
After this competition is established, you can probably come up with many different evolutionary paths depending on where you want to split dragons off from the real evolutionary tree. I would suggest that they started out with the ability to fly, as that's a hard one to develop after you've grown to the size of a small mountain. So perhaps they were flying dinosaurs that survived the extinction event and didn't turn into birds.
Just answering the flying dragon aspect.
I believe that evolutionarily, learning to glide and not plummet straight to your death when jumping off a high surface is a precursor to flight. It's also useful, as mentioned above, in helping get away from predators.
In reverse, some birds have actually evolved with wings and have lost the ability of flight. Eg ostrich and penguins.
If you are wanting you dragons to have evolved from the existing evolutionary tree you can have them gain and lose the ability to fly several times over time. This way, you can incorporate several differing traits from non flying beasts into your various dragon species.
Just seen this video of the 'rare' footage of a peacock flying titled 'the mysterious flight of the peacock' (I think I got my phone to copy the correct link)
That! Right there! Is the beginnings of a magnificent dragon! I actually think they could be halfway there already! Just got to work on fireproofing those feathers!
First off. It's not rare or technically flying. Apparently peacocks somehow get up in tree branches and on top of roofs (especially at night) and then glide off.
With what I've read and heard of peacocks, they are vicious, screeching, argumentative creatures (especially at 4 in the morning) and neighbours hate those birdlovers that rear them in the backyard. Sound like a dragon to you?
And to top it all off, in that video you have the basis of all the assumptions that dragons are vain.