Hi. There is a very long story associated with this. It starts with the very first ideas about moving from the elements Air, Earth, Fire and Water model to the Chemical Elements. Lavoisier isolated a number of the Elements and tried to put them in an order. Read about him here and elsewhere.
Measuring the masses of nuclei was initially done by weighing chemical compounds but now we use a Mass Spectrometer (look it up) for Ions.
After that, physicists thought for a while that atomic nuclei contained protons (which contributed the mass), and electrons (which neutralized the charge of some of the protons). The concept of the neutron as a massive neutral particle (replacing the proton+electron combination) came around 1930-1932.