From Crane, H. R. "The g factor of the electron." Scientific American 218.1 (1968): 72-85.
Samuel A. Goudsmit and George E. Uhlenbeck proposed
... in 1925 that the electron itself had an angular momentum and a
magnetic moment. ... That the electron should have in addition an
intrinsic magnetic moment was part and parcel of the idea that it was
spinning. ... Thus at the time of the discovery of electron spin the g
factor of the electron could be expressed as the number of "natural
units" of magnetic moment (...) divided by the number of "natural
units" of angular momentum (...). When defined in this way, the g
factor for the orbital motion of the electron in its lowest energy
state in hydrogen is 1, whereas the g factor of the free electron is
2. (The g factor as a term designating a ratio of magnetic moment to angular momentum in these special units had been introduced a few
years earlier for the case of the atom by the German physicist Alfred
Lande.) ... In the case of the g factor of the electron, a strong
reinforcement for the belief in the exactness of the value 2 came in
the late 1920's from the new formulation of quantum mechanics by P. A.
Also helpful is Tomonaga, S. The story of spin. University of Chicago Press, 1997
From Enz, Charles P. No time to be brief: A scientific biography of Wolfgang Pauli. Oxford University Press on Demand, 2010.
Chp. 5 The Hamburg years: The curious history of spin.
"But who should now be considered the discoverer of the electron's spin, Pauli, Kronig, or Uhlenbech and Goudsmit?" [p.116].
"That in the history of modern physics the idea of spin has stirred up so much controversy is a strange fact." [p.119].
From Pais, Abraham. Inward bound: of matter and forces in the physical world. Oxford: Clarendon Press, 1986.
"Following a hint by Ehrenfest, George [Uhlenbeck] found in an old article by [M.] Abraham  that an electron considered as a rigid sphere with surface charge only does have g = 2." [p.277]. Similar proposals to Abraham were made by Fitzgerald , Compton  and Kennard . Pauli made a proposal of spin which influenced Goudsmit and Uhlenbeck in 1924. [p.279]. Pais quotes Dirac on the Dirac equation, "It was found that this equation gave the particle a spin of half a quantum. And also gave it a magnetic moment. It gave just the properties that one needed for an electron. That was really an unexpected bonus for me, completely unexpected." [p.286].
From Pippard, Brian. "Magnetic Moments." Rev. of Inward Bound: Of Matter and Forces in the Physical World, by Abraham Pais. London Review of Books 8.15 (1986): 17-18. 16 Nov. 2019 https://www.lrb.co.uk/v08/n15/brian-pippard/magnetic-moments.
Why should anyone wish to know the magnetic moment of the electron to
ten-figure accuracy? The answer is worth giving in some detail as an
exemplary account of the research process. We must return to the early
days of quantum mechanics and the task Dirac set himself in 1927 to
make it consistent with relativity theory, as it was not when first
formulated. In one of the masterpieces of physics he showed that the
restrictions imposed by relativity, as well as others which he
regarded as essential, allowed only one formulation. Applied to the
electron, its solutions described, without any extra assumptions, a
number of properties which the electron had been found experimentally
to possess, but which had not been explained hitherto. Among them was
the magnetic moment whose magnitude is conventionally expressed by a
number g; in Dirac’s theory g turns out to be exactly 2, and the
spectroscopists at the time were satisfied that this agreed with their
extremely precise measurements. There was, however, an exceedingly
curious consequence of the theory: that it permitted electrons to have
negative as well as positive energy, something that is inconceivable
in classical mechanics.
Did anyone mention the possibility of antimatter before 1928?