I'm wondering about the grammar: what role is that "it" playing in that sentence? Is it a personal pronoun or a dummy pronoun?
1.) The word "it" is the grammatical subject -- we know this because of the subject-auxiliary inversion in the interrogative clause.
2a.) Depending on the context, it could be reasonable for a person to consider that the word "it" is a dummy pronoun in a truncated it-cleft construction. (note: A dummy pronoun does NOT have an antecedent.)
2b.) Depending on the context, it could be reasonable for a person to consider that the word "it" is being used in an anaphoric relation to its antecedent which is the baby.
LONG VERSION:
For #2a: In some contexts, the word "it" could be considered to be a dummy pronoun in an it-cleft construction, one that has been truncated and is in the form of an interrogative clause.
A dummy pronoun does not have an antecedent. (Note that a dummy pronoun doesn't have an antecedent because it is not in an anaphoric relation -- that's a reason why it is called a "dummy pronoun".)
It is truncated because the it-cleft's relative clause has been omitted, and this is acceptable when that relative clause can be recovered from the context. This is what a non-truncated version could be:
- "Is it a boy or a girl that she has given birth to?"
A possible declarative clause version of that it-cleft could be:
- "It is a boy/girl that she has given birth to."
A non-it-cleft declarative version could be "She has given birth to a boy/girl".
Here's a related excerpt from the 2002 reference grammar by Huddleston and Pullum et al., The Cambridge Grammar of the English Language, page 1417:
Truncated it-clefts: omission of relative clause
The relative clause of an it-cleft construction can be omitted if it is recoverable from the prior discourse:
[19]
A: Who finished off the biscuits?
B: I don't know; [it certainly wasn't me].
The underlined clause [it is 'bracketed' -- f.e.] here can be analyzed as a truncated it-cleft, equivalent to It certainly wasn't me who finished off the biscuits.
In the OP's post, there is this:
"Mary just wrote to tell us that she's back from maternity leave, and I want to congratulate her and ask whether she had a girl or a boy, but I can't do it without calling the child an 'it'!"
I blinked, then confirmed that yes, he believes the it in "Is it a boy or a girl" is the impersonal pronoun, the same word you'd apply to an apple or a house.
From the above context, a third person (or the OP herself) could have asked the boss a non-trunctated it-cleft such as "Was it a boy or a girl that she had?", though that version sounds awkward when compared to the truncated version "Was it a boy or a girl?"
For #2b: In some contexts, the word "it" could be considered to be in an anaphoric relation, where its antecedent is the baby. For instance, if the baby was already the topic of discussion.
Grammatically, the 3rd person singular neuter pronoun ("it") can sometimes be used to refer to a baby. Here is an excerpt from a 2005 textbook by Huddleston and Pullum, A Student's Introduction to English Grammar, page 103:
The neuter pronoun it is used for inanimates, or for male or female animals (especially lower animals and non-cuddly creatures), and sometimes human infants if the sex is unknown or considered irrelevant: The baby grunted again, and Alice looked very anxiously into its face to see what was the matter with it.
The acceptability for either #2a or #2b as an explanation will usually depend on the specific context of the surrounding discourse. That's the way it is in today's standard English -- context is king.
.
MORE INFO: Perhaps some more general info about the 3rd person singular neuter pronoun ("it"). There are some special uses for it, where those uses for "it" are not anaphoric (or at least not clearly so). These include:
Extrapositional and impersonal it -- e.g. "It's ridiculous that they've given the job to Pat."; "It seemed as if things would never get any better."
The it-cleft construction -- e.g. "It was precisely for that reason that the rules were changed."
Weather, time, place, condition -- e.g. "It is raining."; "It is five o'clock."; "It is very noisy in this room."; "I don't like it when you behave like this."
It as subject with other predicative NPs -- e.g "It was a perfect day."
It in idioms -- e.g. "What's it to you?"; "Beat it, kid"; He made a go of it."
The above info and examples are borrowed from the 2002 CGEL, section "Special uses of it", pages 1481-3.
"It's me/I they want!"
You may be confused because of the existence of sentences like the following:
"I am [whom they want]."
Here, the subject is "I." The complement is the relative phrase "whom they want." The relative pronoun "whom" is prescribed in this context because it is the object of the relative clause.
The sentence you're asking about has a different structure:
"It's me/I [they want]!"
This sentence is definitely not equivalent in structure to "They want me," so just because "me" is the object of that sentence doesn't mean it's an object in your sentence. I actually don't remember if "it" or "me/I" is considered the subject in sentences like this (I'd guess "it" because the verb agrees with it), but it doesn't make a difference for your question because the main verb is "to be". Prescriptively, the complement of the verb "to be" is supposed to have the same case as the subject, which in this case would be the nominative.
Unlike "whom," "I" and "me" are personal pronouns, not relative pronouns, so it's not possible for "me/I they want" to constitute a clause.
Since "me/I is not part of the embedded clause, the case of the pronoun is just determined by its role in the matrix clause (similar to your example "It is I whom they want" or the situations discussed in the following questions: Which is grammatically correct: "Let he who..." or "Let him who...", Is it acceptable to start an emphatic sentence with "It is he who…"?).
So the prescribed form would be “It's I they want!”
But "It's me they want" sounds grammatical to me, and I'm pretty sure to many other English speakers, so that's also OK (see Which one is correct to say: "It's me" or "It's I"?).
Interestingly, though, "It's I" is still more common than "It's me" when followed by a relative clause starting with the subject pronoun "who," according to Barrie England's answer to the following question: It is I who am at fault? Possibly, the reason is because many people find sentences with first-person verb agreement but not "I" (such as "Remember me, who am your friend”) jarring.
“Who is it you asked?”
This is just the question corresponding to the statement "It is __ you asked." When you form a question, the prescriptive rule is that the interrogative pronoun takes the same case as the corresponding word in the equivalent statement. (In normal speech in real life, the situation is more complicated since we can say "It's me" but not "Whom is it?")
Since we established that the pronoun in "It is me/I you asked" is not a grammatical object, we would use "who" and not "whom."
Best Answer
The rule is called Extraposition.
It applies to a sentential subject -- an infinitive clause or a that-clause, for instance:
Extraposition moves those heavy subjects to the end of the sentence, where they are easier to process, and leaves behind a dummy it to (pretend to) be the subject noun phrase. That produces the kind of sentence English likes - starting with a simple subject (preferably a pronoun), followed by a simple verb (preferably an auxiliary verb), with all the complicated stuff piled up at the end.
Whether Extraposition can apply or not is governed by the predicate of the main clause;
be a good idea and be surprising are both predicates that allow it.
Often, as with verbs like seems or looks like, Extraposition is obligatory; the ungrammatical
Extrapose to