Why are wizards in fantasy literature depicted as living in towers?
It is said that a wise man can see more from the bottom of a well than a fool from the top of a mountain, but in reality many of the wise prefer the view from a mountain top.
If there is no mountain, a tower will do.
So I see the following reasons for a tower:
- It's a sign of power and wisdom (any fool can build a hut but a 200m tower takes some clever architecture or it will collapse).
- A tower allows you to see far (so you can hide when your mother-in-law closes in for a new love spell).
- It offers better protection that a hut or house.
- It's not as expensive as a whole castle.
- Astronomy becomes more simple if no leaves disturb the sight.
PS: This is only true for western fantasy. In Asia, wizards usually travel (more like Gandalf; to gather knowledge) or in huts and caves (as to not attract any attention to them by, say, the government).
The trope possibly arose out of 2 sources:
The term "Ivory Tower"
The fact that medieval court wizards would be reputed to be allocated a tower in the castle (ala Merlin in some versions).
From the 19th century it has been used to designate a world or atmosphere where intellectuals engage in pursuits that are disconnected from the practical concerns of everyday life.
The origin of the term, as Wiki notes, is Biblical, but the modern usage dates to a 1837 poem "Pensées d’Août, à M. Villemain", by Charles Augustin Sainte-Beuve, a French literary critic and author, who used the term "tour d'ivoire" to describe the poetical attitude of Alfred de Vigny as contrasted with the more socially engaged Victor Hugo: "Et Vigny, plus secret, Comme en sa tour d’ivoire, avant midi rentrait".
Another notable origin: at Oxford University, the appearance of the Hawksmoor Towers, twin creamy-white neo-gothic towers at All Souls College, Oxford, the only pure research college at Oxford, epitomize the "ivory tower" of Academe.
In that sense, a wizard dealing with what is pure academic pursuit would fit the idea very closely.
There are a number of factors that typically result in wizards living in isolated towers.
A tower sets the wizard apart from the "normal" folk, and helps discourage interruptions and other annoyances. Most settings agree that wizards require a lot of intense research and study. Constant pestering from your neighbors asking you to magick away the fleas infesting their goats, or brew up love potions for some adolescent crush, is not conducive to intense concentration.
It also comes in handy in case the locals decide to blame you for the local drought, or every time a calf is born with two heads (never mind that that really is your fault... If you want to breed a superior magical guardian, sometimes you need to breed a few horrific freaks out of livestock to practice!). The stereotypical torches and pitchforks are considerably less effective against tall stone towers than they are against normal wattle-and-daub.
Some amount of isolation is also useful, particularly if you are practicing magic that could result in large, neighbor-annoying explosions.
A tower is also generally fairly low-maintenance, compared to more complex abodes. A simple stone tower can be reasonably maintained by a single apprentice, or judicious application of a few animated brooms, mops, and brushes.
The trope goes back before Mark Twain (A Connecticut Yankee in King Arthur's Court had the protagonist blow up merlin's tower with gunpowder and a lightning rod). In an actual medieval setting a room in the castle's towers (away from the smell/rats/roaches/flies, best view, less damp and flooding) were high status. If you own more than one book(!) you care about the damp/flooding/rats.
Actual scientists worked similarly: Galileo introduced his telescope to the senate of pisa in a bell tower, and conducted his "what falls faster" experiments off the leaning tower of pisa. Leonardo Davinci lived and worked in various tower rooms (such as the Salla Delle Asse) when he wasn't in upstairs workshops in a monastery (such as Santissima Annunziata).
If you could get a tower it was pretty sweet back, the hard part was building it. (Same logic behind modern skyscrapers, really.) It's the logical way to do "my house has 40 foot walls around it" without sacrificing the ability to have windows.
The main alternative of showing status (having your own castle or monastery) is like a modern rich person with a 40 room mansion for 2 people: kinda pointless unless you have a staff. If you're going to be huddled up in a lab all the time you want maybe one butler/maid who cooks.)
Because the environment might cause side effects for spells and restrict your power. It is a way to be far from other people and living things that are constantly emmiting their own energy and beliefs. You have more power there since you and your spells are much less influenced by nearby energies.