If all harmonics are generated by plucking, how does a guitar string produce a pure frequency sound?

Usually a guitar does not produce a pure tone/frequency. If so, its sound would be very close to a diapason. The difference between noise and a musical tone is not that a tone is made by a unique frequency, but there is a continuum between a pure tone (one frequency) and noise (all frequencies, not only multiple of a fundamental, without any regular pattern among their weights), where many non-pure tones are still recognized as dominated by a fundamental frequency. The additional frequencies add what we call the tone color or timbre of the sound.

In general, the exact weight of each harmonics can be somewhat varid according to how and where the chord is plucked. You might find interesting this study on the subject.

Human perception is involved here because when you humans talk about noise this generally means a sound that is aperiodic. However the tone produced by a guitar will be something like:

$$ A(t,x) = \sum_{i=0}^\infty A_i \sin(n\omega_i t - k_i x) $$

i.e. a superposition of the frequencies $f$, $2f$, $3f$, etc. The function $A(t,x)$ is periodic in time with frequency $f = 2\pi\omega_0$ so the ear/brain team perceives it as a tone not a noise.

Constructing a noise is actually quite complicated as we need to include all frequencies, not just integer multiples of a fundamental, and there will be a phase term in the equation that is not constant i.e. the sine waves making up the noise are not coherent.

For an ideal string, the key point is that all the harmonics are "harmonic" : their frequency is a integer multiple of the frequency of the fundamental. So the movement of the string is periodic and has a well definite frequency.

For an ideal string, the harmonics have frequency ${{f}_{1}}$ , $2{{f}_{1}}$, $3{{f}_{1}}$.....and ${{A}_{1}}\cos (2\pi {{f}_{1}}t)+{{A}_{2}}\cos (2\pi 2{{f}_{1}}t)+{{A}_{3}}\cos (2\pi 3{{f}_{1}}t)....$ is a periodic function of frequency ${{f}_{1}}$

To complete, the dependence in $n$ is rather $\approx 1/{{n}^{2}}$ for a plucked string.

Sorry for my english !