I've heard from some English teachers that word choice should be varied because consistent word choice is boring, but I've heard from a different English teacher that word choice should be consistent. So, should word choice be varied or consistent? Does it matter?
As what's answer notes, academic writing generally values precision (using the most specific words appropriate) and accuracy (using words that most closely match the facts, even avoiding excessive specificity). Effort may be spent avoiding connotations and tone that would emotionally bias the presentation of truth, even avoiding favorable bias. Similarly, musicality of sound may be muted or avoided. Academic writing makes an intellectual appeal and seeks to focus the mind rather than entertain the reader. In addition, academic writing tends to be concise, direct, and didactic; the intent is to express specific facts in a limited time. Academic writing also places greater emphasis on enduring value, which favors staid word choices.
Academic writing can be as boring (or as interesting) to read as a dictionary. Academic writing might be analogous to the stereotype of military rations: nutritious, compact, convenient, and durable but not pretty or delicious.1 Variation in word choice can decrease precision, accuracy, neutrality, and concision.
Journalistic writing may favor much of the tone of academic writing, seeking to appear truthful and objective and valuing the reader's time, but places much greater emphasis on entertainment and accessibility, competing with other content for the reader's attention. Journalists also tend to condescend to the reader's level rather than adopt the role of instructor, presenting news stories as an unfolding of information as if the journalist and the reader are discovering such together.
Analogies for journalistic writing might range from nutrition bars (nutritious — at least by implication —, compact, and convenient, but tasty) to snack food (convenient, tasty, and preferably addictive). Variation in word choice works well with the sense of progressive co-discovery (whether increasing precision, detail, or accuracy) and avoids a dry, academic tone.
Fiction places a much greater emphasis on entertainment and tone, generally works by progressive discovery, and often presents variation in pacing, tone, and perspective.
Fiction might be analogous to an ordinary restaurant meal. Variation in word choice supports a pleasant experience and a growing attachment to the work, the characters and setting, and the author.
The compaction of poetry and its emphasis on form, musicality, and emotion leads to a greater use of variation in word choice. Imprecision or inaccuracy may be not merely acceptable but preferred to move the reader rather than promote a rational conclusion.
Poetry might be analogous to a gourmet dish; attractive, delicious, often small, expensive, and clearly crafted but not necessarily nutritious. For poetry, variation of word choice is particularly important.
Rhetorical writing seeks to evoke an emotional and reasonable response. This leads to some of the qualities of poetry, but repetition is more commonly employed to drive a point home and rational content is used both to provide a more enduring effect and to assist in the communication of the drive to others by the audience. Variation can work against simplistic, forceful presentation but can enhance the musicality and the weight of argument. A synonym can repeat the same fact while appearing as an additional fact.
Rhetorical writing might be somewhat analogous to a box of chocolates, presented in an orderly and appealing manner, delicious, somewhat repetitive, and intended as remembrance ("enduring effect") and gift ("communication ... to others"). Variation in word choice may be used to introduce a taste for the argument in a less committed audience or repeat a common theme without seeming repetitive. Precision, accuracy, and conciseness may be sacrificed for an affective and effective presentation.
As usual with writing (and as hinted by Dale Emery's answer), the target audience and the intention of the writer should guide such choices.
1 Note that academics could learn from the military which is recognizing the importance of the appearance and taste of rations to morale. Just as military success depends on morale, so educational success depends on the interest of the student. Even a conscription army benefits from enthusiastic soldiers and voluntary re-enlistment.
When you're writing for English teachers who require variation in word choice, vary your word choice.
For every other audience, prefer consistency, but don't be a slave to it. Vary the word choice when you have a specific reason to, such as the way the sound of a word fits with the sounds of the words around it.
In general writing, it is good to vary wording to avoid sounding repetitious.
"I drove my car to the car lot where the car salesman sold me a new car." That sounds very awkward, almost silly, because of the repeated use of the same word. If I wanted to express that idea, I'd be much more likely to write, perhaps, "I drove my car to the auto dealer where the salesman sold me a new vehicle."
But in some contexts, using synonyms like this may create an ambiguity. Are you talking about the same thing or something different? This is especially true in technical writing. "Technical" here means not just science and technology but could include history, politics, whatever. For example, suppose you were describing how to repair an electronic device, and you said, "To remove the memory chip from the circuit board, grasp the part on the left and pull the component to the right." Someone might well ask, "by 'the part' do you mean the memory chip, or the circuit board?" Or if in a discussion of space travel you switched between the words "rocket", "space craft", and "space ship", a reader might not be clear if you are using these words as synonyms or are making a technical distinction. Etc. In such cases, it is better to use the same word repeatedly for clarify, even if it doesn't "sound nice".