Many, many answers to this one already, but, in the framework of Pythagorean tuning, there actually is a clear mathematical distinction between black keys and white keys that has not yet, I think, been explicitly stated.
The division of the chromatic scale in $7$ natural notes (white keys in a piano) and $5$ accidental ones (black) seems a bit arbitrary to me.
Apparently, adjacent notes in a piano (including white or black) are always separated by a semitone. Why the distinction, then?
In equal temperament, the ratio of the frequencies of two pitches separated by one semitone is $\sqrt[12]{2}$, no matter what the pitches are. But in other tunings, the ratio cannot be kept equal. In Pythagorean tuning, which tries to make fifths perfect as far as possible, there are two different types of semitone, a wider semitone when the higher pitch is a black key, and a narrower semitone when the higher pitch is a white key. Hence, in Pythagorean tuning at least, there is a clear mathematical distinction between white keys and black keys.
Of course, which notes are white keys and which are black keys depends on which note is used to start building the scale. Starting from $F$ produces the traditional names for the keys.
To see how this works, start from $F$ and generate ascending fifths,
$$
F,\ C,\ G,\ D,\ A,\ E,\ B,\ F\sharp,\ C\sharp,\ G\sharp,\ D\sharp,\ A\sharp,
$$
with frequencies in exact $\frac{3}{2}$ ratios (dividing by $2$ as needed to keep all pitches within an octave of the starting $F$). You find that you cannot add the $13^\text{th}$ note, $E\sharp$, without coming awfully close to the base note, $F$. The separation between $F$ and $E\sharp$ is called the Pythagorean comma, and is roughly a quarter of a semitone. So if you stop with $A\sharp$, you have divided the octave into $12$ semitones, which you discover are not all the same. Five of the $12$ semitones are slightly wider than the other seven. These two distinct semitones are called the Pythagorean diatonic semitone, with a frequency ratio of $\frac{256}{243}$ or about $90.2$ cents, and the Pythagorean chromatic semitone, with a frequency ratio of $\frac{2187}{2048}$ or about $113.7$ cents. (In equal temperament, a semitone is exactly $100$ cents. The number of cents separating $f_1$ and $f_2$ is defined to be $1200\log_2f_2/f_1$.) The Pythagorean diatonic semitone and the Pythagorean chromatic semitone differ from each other by a Pythagorean comma (about $23.5$ cents).
You find that the semitone ending at $F$, that is, the interval between $E$ and $F$, is a diatonic semitone, whereas the semitone ending at $F\sharp$, that is, the semitone between $F$ and $F\sharp$, is a chromatic semitone. The other diatonic semitones end at $G$, $A$, $B$, $C$, $D$, and $E$, while the other chromatic semitones end at $G\sharp$, $A\sharp$, $C\sharp$, and $D\sharp$.
Some things to note:
- If you start with a note other than $F$, the diatonic and chromatic semitones will be situated differently, but you will always end up with seven diatonic ones and five chromatic semitones, with the chromatic semitones appearing in a group of three and a group of two as in the traditional keyboard layout.
- A great many tuning systems have been devised, which play with the definitions of the semitones or introduce new ones. It is only in equal temperament that the distinction between the two semitones is completely erased.
Some additional detail: starting from the octave, one can progressively subdivide larger intervals into smaller ones by adding notes from the progression of fifths. At the initial stage you have the octave.
$$
\begin{array}{c|c|c|c}
\text{note} & \text{freq.} & \text{ratio to prev.} & \text{ratio in cents}\\
\hline
F & 1 & \\
F & 2 & 2 & 1200
\end{array}
$$
Interpolating a note a fifth higher than $F$ divides the octave into two unequal intervals, a fifth and a fourth. (Added notes will be shown in red.)
$$
\begin{array}{c|c|c|c}
\text{note} & \text{freq.} & \text{ratio to prev.} & \text{ratio in cents}\\
\hline
F & 1 & \\
\color{red}{C} & \color{red}{\frac{3}{2}} & \color{red}{\frac{3}{2}} & \color{red}{702.0}\\
F & 2 & \frac{4}{3} & 498.0
\end{array}
$$
Adding a third note, the note a fifth above $C$, splits the fifth into a whole tone (ratio $\frac{9}{8})$ and a fourth.
$$
\begin{array}{c|c|c|c}
\text{note} & \text{freq.} & \text{ratio to prev.} & \text{ratio in cents}\\
\hline
F & 1 & \\
\color{red}{G} & \color{red}{\frac{9}{8}} & \color{red}{\frac{9}{8}} & \color{red}{203.9}\\
C & \frac{3}{2} & \frac{4}{3} & 498.0\\
F & 2 & \frac{4}{3} & 498.0
\end{array}
$$
Two more additions split the fourths and produce the pentatonic scale, which is built of whole tones and minor thirds.
$$
\begin{array}{c|c|c|c}
\text{note} & \text{freq.} & \text{ratio to prev.} & \text{ratio in cents}\\
\hline
F & 1 & \\
G & \frac{9}{8} & \frac{9}{8} & 203.9\\
\color{red}{A} & \color{red}{\frac{81}{64}} & \color{red}{\frac{9}{8}} & \color{red}{203.9}\\
C & \frac{3}{2} & \frac{32}{27} & 294.1\\
\color{red}{D} & \color{red}{\frac{27}{16}} & \color{red}{\frac{9}{8}} & \color{red}{203.9}\\
F & 2 & \frac{32}{27} & 294.1
\end{array}
$$
We may split each of the minor thirds into a whole tone and a (diatonic) semitone, which produces the diatonic scale.
$$
\begin{array}{c|c|c|c}
\text{note} & \text{freq.} & \text{ratio to prev.} & \text{ratio in cents}\\
\hline
F & 1 & \\
G & \frac{9}{8} & \frac{9}{8} & 203.9\\
A & \frac{81}{64} & \frac{9}{8} & 203.9\\
\color{red}{B} & \color{red}{\frac{729}{512}} & \color{red}{\frac{9}{8}} & \color{red}{203.9}\\
C & \frac{3}{2} & \frac{256}{243} & 90.2\\
D & \frac{27}{16} & \frac{9}{8} & 203.9\\
\color{red}{E} & \color{red}{\frac{243}{128}} & \color{red}{\frac{9}{8}} & \color{red}{203.9}\\
F & 2 & \frac{256}{243} & 90.2
\end{array}
$$
Adding five more fifths splits each of the five whole tones into a chromatic semitone and a diatonic semitone to produce the chromatic scale.
$$
\begin{array}{c|c|c|c}
\text{note} & \text{freq.} & \text{ratio to prev.} & \text{ratio in cents}\\
\hline
F & 1 & \\
\color{red}{F\sharp} & \color{red}{\frac{2187}{2048}} & \color{red}{\frac{2187}{2048}} & \color{red}{113.7}\\
G & \frac{9}{8} & \frac{256}{243} & 90.2\\
\color{red}{G\sharp} & \color{red}{\frac{19683}{16384}} & \color{red}{\frac{2187}{2048}} & \color{red}{113.7}\\
A & \frac{81}{64} & \frac{256}{243} & 90.2\\
\color{red}{A\sharp} & \color{red}{\frac{177147}{131072}} & \color{red}{\frac{2187}{2048}} & \color{red}{113.7}\\
B & \frac{729}{512} & \frac{256}{243} & 90.2\\
C & \frac{3}{2} & \frac{256}{243} & 90.2\\
\color{red}{C\sharp} & \color{red}{\frac{6561}{4096}} & \color{red}{\frac{2187}{2048}} & \color{red}{113.7}\\
D & \frac{27}{16} & \frac{256}{243} & 90.2\\
\color{red}{D\sharp} & \color{red}{\frac{59049}{32768}} & \color{red}{\frac{2187}{2048}} & \color{red}{113.7}\\
E & \frac{243}{128} & \frac{256}{243} & 90.2\\
F & 2 & \frac{256}{243} & 90.2
\end{array}
$$
There is no fundamental reason to stop here. Adding five more fifths creates a $17$-note scale by dividing each of the wider chromatic semitones into a new small interval, the Pythagorean comma (frequency ratio $531441/524288=3^{12}/2^{19}$ or about $23.5$ cents), and a diatonic semitone. We call the new notes $E\sharp$, $B\sharp$, $F\sharp\sharp$, $C\sharp\sharp$, $G\sharp\sharp$. Note that $E\sharp$ is a Pythagorean comma higher than its enharmonic equivalent $F$, $B\sharp$ is a Pythagorean comma higher than its enharmonic equivalent $C$, $F\sharp\sharp$ is a Pythagorean comma higher than its enharmonic equivalent $G$, and so on.
$$
\begin{array}{c|c|c|c}
\text{note} & \text{freq.} & \text{ratio to prev.} & \text{ratio in cents}\\
\hline
F & 1 & & \\
\color{red}{E\sharp} & \color{red}{\frac{531441}{524288}} & \color{red}{\frac{531441}{524288}} & \color{red}{23.5}\\
F\sharp & \frac{2187}{2048} & \frac{256}{243} & 90.2\\
G & \frac{9}{8} & \frac{256}{243} & 90.2\\
\color{red}{F\sharp\sharp} & \color{red}{\frac{4782969}{4194304}} & \color{red}{\frac{531441}{524288}} & \color{red}{23.5}\\
G\sharp & \frac{19683}{16384} & \frac{256}{243} & 90.2\\
A & \frac{81}{64} & \frac{256}{243} & 90.2\\
\color{red}{G\sharp\sharp} & \color{red}{\frac{43046721}{33554432}} & \color{red}{\frac{531441}{524288}} & \color{red}{23.5}\\
A\sharp & \frac{177147}{131072} & \frac{256}{243} & 90.2\\
B & \frac{729}{512} & \frac{256}{243} & 90.2\\
C & \frac{3}{2} & \frac{256}{243} & 90.2\\
\color{red}{B\sharp} & \color{red}{\frac{1594323}{1048576}} & \color{red}{\frac{531441}{524288}} & \color{red}{23.5}\\
C\sharp & \frac{6561}{4096} & \frac{256}{243} & 90.2\\
D & \frac{27}{16} & \frac{256}{243} & 90.2\\
\color{red}{C\sharp\sharp} & \color{red}{\frac{14348907}{8388608}} & \color{red}{\frac{531441}{524288}} & \color{red}{23.5}\\
D\sharp & \frac{59049}{32768} & \frac{256}{243} & 90.2\\
E & \frac{243}{128} & \frac{256}{243} & 90.2\\
F & 2 & \frac{256}{243} & 90.2
\end{array}
$$
In the next few iterations,
- $12$ fifths are added, shaving a Pythagorean comma off of each diatonic semitone, thereby producing a $29$-note scale with $17$ Pythagorean commas ($23.5$ cents) and $12$ intervals of $66.8$ cents;
- $12$ more fifths are added, shaving a Pythagorean comma off of each $66.8$ cent interval, thereby producing a $41$-note scale with $29$ Pythagorean commas ($23.5$ cents) and $12$ intervals of $43.3$ cents;
- $12$ further fifths are added, shaving a Pythagorean comma off of each $43.3$ cent interval, thereby producing a $53$-note scale with $41$ Pythagorean commas ($23.5$ cents) and $12$ intervals of $19.8$ cents.
Note that at some steps in this process the two intervals obtained are more nearly equal than at others, and that those scales whose intervals are nearly equal are very well approximated by an equal-tempered scale. The lengths of the scales where this happens coincide with denominators of convergents of the continued fraction expansion of $\log_2 3$, that is, at $2$, $5$, $12$, $41$, $53$, $306$, $665$, etc. A spectacular improvement is seen in the $665$-note scale, where the two intervals are $1.85$ cents and $1.77$ cents. In contrast, the intervals in the $306$-note scale are relatively far apart: $5.38$ cents and $3.62$ cents. From this perspective, the $12$-note scale is remarkably good.
I should emphasize that this is only the barest beginning of a discussion of tuning systems. It is desirable to accommodate small whole number ratios other than $\frac{3}{2}$ such as $\frac{5}{4}$ (the major third) and $\frac{6}{5}$ (the minor third), which necessitates various adjustments. It is also desirable to be able to play music in different keys, which forces other compromises. Many of these issues are discussed in the other answers.