It is a long walk to school.

(What does 'It' refer to? What does 'to school' modify in the sentence? Is 'to school' an adverbial phrase?)

"It" is just one of those generic uses that doesn't refer to any particular noun. This construction also occurs in these:

It's very hot today.
It's raining cats and dogs outside.
It's a great day for a picnic.

Yes, "to school" is an adverbial use of the infinitive in this sentence.