Thomson was trying to understand in more detail the structure of the atom. With his cathode ray tube he was able to generate electrical discharges in gas molecules. When he did this a stream of charges was generated. By using a combination of electrical and magnetic fields he was able to determine that the charge was negative in nature. He had discovered the electron! He then did additional studies looking at the charge to mass ratio of these charges and determined the charge of a single electron.
Based on his finding he proposed a model of matter in which negative charges were scattered around inside all substances. Being familiar with plum pudding, in which plums are at random places within the pudding base, his model was referred to as the "plum pudding model".