The it in both example sentences is, as noted, a "dummy it" -- that is, this it is not referential,
and thus doesn't have any meaning, because meaning in pronouns is a matter of reference only.
This dummy it (there are several others) is an artifact of a syntactic rule called Extraposition, which works to make sure that "heavy" subject noun phrases (clauses and the like) don't show up
at the beginning of the sentence where they're hard to process, like this unwieldy example:
- For a child to open this package is difficult.
Instead, Extraposition inserts a dummy it in place of the heavy NP and shifts it to the end,
where it is much easier to process.
- It is difficult for a child to open this package.
Of course, Extraposition is governed by the matrix predicate (in this case be difficult), and some predicates require it, others forbid it, and many allow it under certain circumstances. Like all syntactic rules; nothing new here.
As the the original question -- what is it?
The answer is that it's several things:
- it's a pronoun
- it's a dummy (i.e, it's a pronoun with no reference)
- it's the subject of the sentence