For a good (and extremely accessible) overview of the various roles of "variables" in mathematics, see Conceptions of School Algebra and Uses of Variables by Zalman Usiskin. The introduction lays out the terrain quite well:
Consider these equations, all of which have the same form —- the
product of two numbers equals a third:
- $A=LW$
- $40=5x$
- $\sin x=\cos x \cdot \tan x$
- $1=n \cdot (1/n)$
- $y=kx$
Each of these has a different feel. We usually call (1) a formula, (2)
an equation (or open sentence) to solve, (3) an identity, (4) a
property, and (5) an equation of a function of direct variation (not
to be solved). These different names reflect different uses to which
the idea of variable is put. In (1), $A$, $L$, and $W$ stand for the
quantities area, length, and width and have the feel of knowns. In
(2), we tend to think of $x$ as unknown. In (3), $x$ is an argument of
a function. Equation (4), unlike the others, generalizes an arithmetic
pattern, and $n$ identifies an instance of the pattern. In (5), $x$ is
again an argument of a function, $y$ the value, and $k$ a constant (or
parameter, depending on how it is used). Only with (5) is there the
feel of “variability,” from which the term variable arose. Even so,
no such feel is present if we think of that equation as representing
the line with slope $k$ containing the origin.
Conceptions of variable change over time. In a text of the 1950s (Hart
1951a), the word variable is not mentioned until the discussion of
systems (p. 168), and then it is described as “a changing number.” The
introduction of what we today call variables comes much earlier (p.
11), through formulas, with these cryptic statements: “In each
formula, the letters represent numbers. Use of letters to represent
numbers is a principal characteristic of algebra” (Hart’s italics).
In the second book in that series (Hart 1951b), there is a more formal
definition of variable (p. 91): “A variable is a literal number that
may have two or more values during a particular discussion.”
Modern texts in the late part of that decade had a different
conception, represented by this quote from May and Van Engen (1959) as
part of a careful analysis of this term:
Roughly speaking, a variable is a symbol for which one substitutes names for some objects, usually a number in algebra. A variable is
always associated with a set of objects whose names can be substituted
for it. These objects are called values of the variable. (p. 70)
Today the tendency is to avoid the “name object” distinction and to
think of a variable simply as a symbol for which things (most
accurately, things from a particular replacement set) can be
substituted.
The “symbol for an element of a replacement set” conception of
variable seems so natural today that it is seldom questioned. However,
it is not the only view possible for variables. In the early part of
this century, the formalist school of mathematics considered variables
and all other mathematics symbols merely as marks on paper related to
each other by assumed or derived properties that are also marks on
paper (Kramer 1981).
I will resist the temptation to quote additional large chunks of the Usisikin's text, but the rest of the paper does an exemplary job of distinguishing among the different conceptions of "variable" in mathematics, and how those conceptions relate to different conceptions of what "algebra" is.