There is no rule for avoiding it. However, as with all words, you should avoid repetition and make sure your text is readable. Your first sentence is perfectly fine. Just make sure you choose different words to refer to something. If you're talking about Obama, you shouldn't repeat the word Obama all the time. Instead, vary by using the President of the US, the head of state, POTUS or even words such as the man, he, leader and so on.
What follows is a bit more explanation on varying in word choice in texts by using referential words:
The word it as used in your sentence is what we call an anaphor. This means that it is a word referring back to something mentioned earlier in the text. The other two types of 'phor' are the cataphor (referring to something mentioned after the cataphor itself) and the exophor (referring to something outside the text.
Now, anaphors in particular are used to avoid repetition of the same word in your text. You replace a mentioned word, phrase or entire clause with synonyms, pronouns or anything else that could possibly express the same meaning. Let me give you an example:
- I dropped my phone. It broke.
- I sang a song, and that was not appreciated by the audience.
Anaphors are used in order to keep a certain part of the text in the reader's mind. For example, if you introduce someone by name in the first paragraph of a text, you cannot all of a sudden refer to that person again using he or she after 100 lines of text if you did not continue on that subject and kept using anaphors to keep that person in your reader's mind. If you then want to talk about that person again, you could use for example:
The person we talked about in the first paragraph.
The longer the distance between the anaphor and the referent, the more explicit you will have to be. The short example sentences I gave above could use it and that. This is because their referents were very close, meaning that not much explicitation is needed to bring the referent back tot he readers mind.
Other than anaphors, you can also use words that link the context in order to keep your text flowing:
I dropped my phone. Its screen cracked. I now won't be able to access my contacts.
Though these words are not synonyms, they refer to each other. Without the first phrase, the second and third ones wouldn't make much sense. The words in bold in the second and third sentence remind the user that we are talking about my phone still.
In your examples, both are correct, but it depends on what you are referring to
It is a pair of shoes.
It is a pair of two halves.
It is a pair
in these examples one is describing the "pair"edness of the objects.
They are a pair of shoes.
Those are a nice pair of melons.
two somethings are a pair
in these examples one is describing the objects as a "pair".
Best Answer
B might make sense, but it's not idiomatic. It's true that pair is a count noun in that you can have one pair or two pairs. But when you are referring to both shoes of the pair, we use a plural pronoun.
So, it's take them away because both shoes are dirty.
If only one shoe of the pair of shoes is dirty, we wouldn't normally say this pair of shoes is dirty but this shoe is dirty or the right/left shoe (of this pair of shoes) is dirty. In that case you're talking about one shoe so use it: Take it (the dirty shoe) away.
Again if only shoe was dirty and you said Take them away, you might get a puzzled look from whoever you're talking to, because they would associate it not with one pair but with one shoe; thus they might wonder why you're saying to take only one dirty shoe away if both are dirty. Yes, it might "make sense" to say Take it away and have it refer to the pair of dirty shoes, but that's not how native speakers normally use and match the pronouns with the nouns in this context.