The quantum operators form the Virasoro algebra, where the generators obey $[L_m,L_n]=(m-n)L_{m+n}+\frac{c}{12}m(m^2-1)\delta_{m+n,0}$. Here "c" is the central charge, which is the space-time dimension we are working over. We need this algebra to interact appropriately with the physical states of the system (i.e. $L_m|\phi\rangle$ information), and only when $c=26$ do we guarantee that there are no negative-norm states in the complete physical system.
[Addendum] In the method I described, $c=26$ arises correctly as the critical dimension so that no absurdities occur. What I believe David Roberts is thinking about (in his comment below) is another way to get the same answer: You consider light-cone coordinates and write down the mass-shell condition (summing over the worldsheet dimension $D−2$), and you end up with the requirement $\frac{D-2}{24}=1$. In other words, $c=D=26$.
The quantum operators form the Virasoro algebra, where the generators obey $[L_m,L_n]=(m-n)L_{m+n}+\frac{c}{12}m(m^2-1)\delta_{m+n,0}$. Here "c" is the central charge, which is the space-time dimension we are working over. We need this algebra to interact appropriately with the physical states of the system (i.e. $L_m|\phi\rangle$ information), and only when $c=26$ do we guarantee that there are no negative-norm states in the complete physical system.