The structure of a molecule determines how it will fall apart. That is, the mass spectrum is a snapshot of the decomposition chemistry. The concept of functional group is quite important in the interpretation of mass spectra.