The following explanation will use some mathematics, if that is not your thing, you can skip to the last paragraph where I will paraphrase the explanation.
Say we have a string of length #L#. So if we assign a coordinate #x# on the string given by the distance from one of the endpoints to the point #x# on the string. This means that #x# ranges from #0# to #L#.
The sound of the string is produced by vibration of the string, meaning that the amplitude of the string at each point #x# (the distance that the string has moved away from the point where it would be when in rest) varies with time. This means it is possible to assign a function giving the movement of the string causing the sound, #u(x,t)#, which gives the amplitude of the string at each point #x# and time #t#.
For an understanding of what we mean by frequencies which fit the string, we need to know the following. When a function is only given on a finite interval (in this case from #0# to #L#), it is possible to write a function as a sum of sines and cosines which are periodical in #2L# (this is known as the Fourier series of a function).
With sines and cosines that are periodical in #2L#, we mean that we have functions #cos(2pi x/P)#, #sin(2pi x/P)# with some period #P#, so that #cos(2pi x/P)=cos(2pi (x+2L)/P)# and #sin(2pi x/P)=sin(2pi (x+2L)/P)#.
This means that #2L/P=n# with #n# a whole number. So #P=n/(2L)#.
So we can write these functions as sums of #cos((npix)/L)# and #sin((npix)/L)# with #n# some whole number.
More to the point, a function #f(x)# where #x# ranges from #0# to #L# can be represented as follows:
#f(x)=sum_na_ncos((npix)/L)+b_nsin((npix)/L)#
Where #a_n# and #b_n# are some coefficients. (There is a way to calculate these coefficients given the function #f#, if you're curious on how to do that, google Fourier series or just ask me.)
Now we are going to apply this to our problem with the string. Remember that we had the function #u(x,t)# describing the movement of the string. Since it is defined for #x# from #0# to #L#, we can write it down as a Fourier series. Note that the function also depends on #t#, so the coefficients #a_n# and #b_n# will be depending on #t#.
#u(x,t)=sum_na_n(t)cos((npix)/L)+b_n(t)sin((npix)/L)#
If we were just to rely on mathematics, this would be the end, luckily this is a physics question, so we have the laws of physics helping us out. There is an equation telling us how this function #u(x,t)# behaves, known as the wave equation. It can be derived from viewing a string as a chain of tiny springs, and making use of Hooke's law, but that would go beyond the scope of this text. Here I will just give the equation.
#(del^2u)/(delt^2)=v^2(del^2u)/(delx^2)#
Here #v# is the propagation speed of a wave through the string, which varies with the density and tension of the string.
This equation is a linear differential equation, meaning that if we have found solutions, the sum of these solution will also be a solution. Using the Fourier series above, we see that we only have to find solutions of functions of the form #a(t)cos(cx)# and #a(t)sin(cx)# with #c# a constant.
Let #u(x,t)=a(t)cos(cx)#.
#(del^2u)/(delt^2)=a''(t)cos(cx)#
#(del^2u)/(delx^2)=-c^2cos(cx)#
Putting this into the wave equation (dividing out #cos(cx)#) gives:
#a''(t)=-(cv)^2a(t)#
This has the solutions #a(t)=Acos(cvt)+Bsin(cvt)# with #A,B# some constants.
This is a sinewave, so we can assign a frequency to it, namely #(cv)/(2pi)#.
This gives us the following result:
#u(x,t)=sum_na_n(t)cos((npix)/L)+b_n(t)sin((npix)/L)#
where #a_n(t),b_n(t)# are sinewaves with frequency #(nv)/(2L)#.
So only the frequencies #(nv)/(2L)# with #n# some whole number fit into the string. The fundamental tone is given by the lowest frequency, #v/(2L)#, and the other frequencies the overtones. The fundamental tone is often the dominant term in the Fourier series, but this is not guaranteed. It is worth noting that the longer the string is, the lower the fundamental tone.
Paraphrasing: The vibration of a string can be thought of as a sum of contributions vibrating with discrete frequencies. Due to the physical nature of the string, we can relate these frequencies to the length of the string. The fundamental tone is given by the lowest of these frequencies, the higher frequencies give the overtones.