Before Pan's Labyrinth (2006), Guillermo del Toro made another gothic horror story about the Spanish Civil War. That's not the only connection/parallel we could make between The Devil's Backbone and Pan's Labyrinth: both feature kids caught up in the fight; both feature semi-isolated, fortress-like homes; both internalize the historical fight as a domestic, romantic drama. But that's pretty vague, so let's get into particulars.
One thing that this film does brilliantly is put so many quickly-sketched characters into play, so it can play with lots of different conflicts. The new rich kid at the "orphanage" comes into conflict with the orphanage tough; but the friendly orphan, by being friends with the new kid, is put into a position of conflict with many of the other orphans. Meanwhile, the orphans are afraid of the young caretaker, who wants to keep his past as an orphan secret and find the Republican gold so he can run away with the young woman. But this caretaker is also having sex with the orphanage administrator, who is loved by the old (and impotent) orphanage doctor. And further meanwhile, there's the war that threatens to overwhelm this orphanage.
And there's the ghost--or ghosts.
Now, most of those characters are not all that rich or deep. The bully is secretly haunted by his moment of weakness; the caretaker who seems to be a bully... turns out to be a pretty awful bully when pushed by circumstances. But even without a set of complex, rich characters, it seems to work because there are so many and each is well crafted in his or her specific role.
It also works so well because each scene remains sharp and surprising. Take, for instance, a scene where the orphan bully comes to threaten the new kid by the underground cistern. It starts with that normal bullying scene, but when the new kid knocks the bully into the cistern, suddenly he has to rescue the bully. Then the caretaker comes to threaten the kids in his own way. So this scene quickly shifts and escalates the conflict, which keeps our attention and interest. And after that scene, we might expect the bully to relent--but he's still not interested in being friends yet. Which nicely subverts the expected cliche.
Almost the weakest element of the story is the ghost/ghosts, who change quickly from threatening unknowns to helpful spirits. By the end of the story, we're not worrying about the kids anymore, but just waiting to see how the antagonists will get it, now that the kids AND the ghosts are hostile.