May I add the following:
The Spectrum Analyser can only handle a certain signal power level. If it is too high, you risk damaging the input stage. This is written next to the input connector! i.e. "MAX +10dBm"
The attenuator allows to lower the signal power level, so that the remaining signal is "safe".
As ntnico said, if you attenuate the signal too much, you won't distinguish the signal from the noise. Hence why you need a configurable attenuation.
If you use the internal attenuator, the spectrum analyzer will automatically do the math plus the attenuation has been calibrated (it is never perfectly flat across the frequency range).
If you use an external attenuator, then you need to subtract its attenuation from the displayed values, as the spectrum analyser obviously just measures the input signal, not knowing what you have done with it outside the spectrum analyser.
For example, if you are dealing with antennas and/or transmitters, it is easy to exceed the maximum input rating. Doing so will quickly break the spectrum analyser. What I do is to connect a switchable external attenuator, that has a range up to -60dB (if I am not mistaken). I start with the biggest attenuation and lower it, always keeping an eye if the input signal is under the spectrum analyser's rating (written on the Input connector). Ideally, the signal does not need any external attenuation - but I like to be on the safe side.
In order to get you as paranoid as myself: if you are using i.e. a cheap Baofeng radio transmitting 5W and hold the antenna close enough to the spectrum analyser's input connector, you may break it, as 5W are roughtly 37dBm!
Spectrum analysers are sensitive equipments.
Why don't you consider buying yourself a cheap "SMA Simple Spectrum Analyser" device for aruond 50 Eurio from Chinese eBay? It can do 35MHz up to 4GHz and you can run it with my software (
http://vma-satellite.blogspot.pt/2016/12/vma-simple-spectrum-analyser-download.html). This gives you a cheap introduction to spectrum analysis with little risks.
Also, do read the manuals of spectrum analysers! You will learn a lot without spending any money.
Regards,
Vitor