They are not equivalent. "On the way" means that the location or object is along, adjacent to, or near some route.
If we're going to John's house, can we stop by the store to pick up some snacks? It's on the way.
"In the way" means that the location or object is directly in the path or blocking that route.
You used to be able to see the ocean from that hotel, but recently they built a larger hotel that's in the way.
Another way to think about it is that something "on the way" is convenient, while something "in the way" is an obstruction. It's possible to have both in the same sentence:
On the way to Lauren's house out in the country, we were delayed by a herd of cows that were in the way.
Moreover, "on the way" only really makes sense when talking about something related to people, or other entities that have the ability for conscious choice, even if it's only to specify some point of interest.
The restaurant is on the way to our hotel, if you want to stop for a quick bite.
"Fire" would not qualify, as it is mindless. A fire would not stop at a corner store to pick up a bag of chips (a.k.a. crisps) on its way to burn a town. Instead it might burn down the store, if it was in the way, which is what you should use in this case:
The fire consumed everything in its way.
I can't think of any case where you can freely substitute one for the other without changing the meaning.
(Edit) In the case where you're talking about a conscious entity acting as a destructive force (such as an army), which you use depends on what you want to say. For example, if you want to imply the army was engaged in wanton destruction then, as with fire, "in the way" makes more sense.
During the march south, the Union army indiscriminately torched any towns that were in the way.
On the other hand, if you want to imply the army was consciously selecting targets for destruction, then "on the way" would work:
During the march south, the Union army deliberately torched railways, supply caches, farms, factories, and anything else on the way that might be of strategic value to the Confederates.