1. It is not far from here.

2. It takes three hours from here to the station by car.

---------------------------
Does "it" in each sentence have the same function? Does the "two it's" have the same grammatical role?

Yes, both instances of "it" are the same here: that impersonal "it" that has no particular antecedent.

thank you for your help.

-------------------
I know a good Italian restaurant. It¡¯s not far from here, either.

(In this sentence, "it" refers to "a good Chinese restaurant," isn't it?
Does it have any difference from the first question?)

Yes, in this sentence, "it" has a specific antecedent: restaurant.

In both sentences, "it" is being used as a pronoun. However, the roles of "it" in each sentence are different.

In the first sentence, "it" is referring to an unspecified location that is relatively close to the speaker's current position. This usage of "it" is often used when referring to a place or destination.

In the second sentence, "it" is referring to the duration of time it takes to travel from the speaker's current position to the station. This usage of "it" is commonly used when talking about time or measurements.

So, while both instances of "it" are pronouns, they have different functions and refer to different aspects of the sentences.