1. Is it okay if I open the window?

(What does 'it' refer to in this sentence?)

2. Do you mind if I borrow your pen?

(What is the meaning of 'mind' in this sentence?)

1. "Is it okay..." is an idiomatic expression that is a casual way to ask permission. The word "it" doesn't have any particular antecedent, just as in the following idioms:

It's raining today.
It's really hot and humid outside.

2. In this expression, the phrase "do you mind" is another way to ask permission. It's approximate meaning is "Is it all right if I ... ?"