No wonder you find this puzzling: from the grammar point of view, this specific construction is quite difficult. I've found a 15-page study of this construction that explains it pretty well, though.
In short: a construction such as It is difficult to explain can also be written in English as Explaining it is difficult. I'll use a different subject to make this clearer:
History is difficult to explain => Explaining History is difficult
The construction pattern is
to be +
infinitive, where the adjective qualifies the noun and the infinitive acts as modifier of the adjective, but the noun is also the object of the verb (what is difficult to explain? History).
In these cases, the appropriate preposition to use in Spanish is de:
Es difícil de explicar
Once again, the example with a different subject and both forms:
Tu comportamiento es difícil de explicar => Es difícil explicar tu comportamiento (or: explicar tu comportamiento es difícil)
This construction works with many different adjectives:
Tu comportamiento es difícil de explicar
La lección es fácil de entender
La película es imposible de olvidar
El examen está pendiente de corregir
Una camisa cómoda de llevar
As you can see in the last examples, the verb ser can be replaced by others, such as estar, or even omitted altogether; but the construction is still the same. In all those cases, the subject of the sentence (or proposition) also works as object of the infinitive that modifies the article.
DETERMINER + INFINITIVEis used for verbs that don't tend to allow the subject as also the direct object.