Saying it comes from G7 with altered notes is a bit "chicken or egg". Where did the altered notes come from?
this is an interesting question.
It would be interesting to find Barry Harris talking about it, since the practise started in pre-modal (1959) times.
Before that we find two scales useful for altering a dominant chord: octatonic and whole tone, both fashionable among French composers at the beginning of the century and included in the jazz language (Gonsalves on the octatonic and Monk on the wholetone spring to mind).
These give the sounds then included in the so-called "altered" scale: four notes from the 8tonic (b9 b10 3) then a WT.
But there is also IVm7 substitution (Fm7 over G7) that was not uncommon and has that b9 and an amazing fourth on a dominant chord (red Garland)
Vertically: Dm G7 C
Let's sharpen the 11th on G7 (= let's raise the root of the original scale C# D E....)*
Tritone subtitution: Dm |C#7 (#11)| C
Let's pretend that C#7 is the dominant of F# with a raised root (F##, G#,A#, B....): Here is the altered scale on G7 (enharmonic of F##)
This is more likely to be the origin of the altered dominant chord, but I am ready to change my mind if earlier examples in contact with jazz are found.
*this is already the C# altered scale