I have been searching for a while now and I came to the conclusion that when you fix the aperture ring of Nikon 1.4D lens on lowest stop, then we can change the aperture using command dial, plus the 1.4D version also provides the auto focus on bodies with a built-in AF motor. Why then buy the 50mm 1.4G or 1.8G instead of 1.4D or 1.8D?
The two Nikon G lenses mentioned in the question are AF-S lenses that have an internal focus motor and can be used with any modern Nikon DSLR with auto focus fully functional. The two Nikon D lenses mentioned in the question are AF lenses that do not have an internal focus motor and must be used with a camera body that includes a focus motor in the body via a mechanical linkage if autofocus is desired.
The D3xxx and D5xxx series bodies (as well as some, but not all of the older Dxx bodies) do not have an focus motor in the body and require an AF-S lens for autofocus. The AF Nikkor D lenses must be focused manually when used on a non-motorized body.
Even when using a body that does include a focus motor, the Silent Wave motors in most AF-S lenses are faster and quieter than the camera's focus motor and screw drive linkage. The optics in the G series of lenses are newer and generally better than the optics in most of the corresponding D series lens.
For more regarding the differences between these two particular 50mm f/1.8 lenses, please see What's the difference between using a 50mm f/1.8G and a 50mm f/1.8D with a Nikon D80?
This is actually incorrect. AF-S indicates the presence of an internal motor. G indicates that the aperture is controlled by the body and lack an aperture ring whereas D lenses have one. Aug 14, 2016 at 11:10
@JamesSnell Technically all G lenses are also D lenses (because they communicate distance information to compatible bodies), and Nikon seems to always have a lens or two that defies their own naming conventions. The vast majority of G lenses are also AF-S lenses. Most D lenses are also AF lenses. There are some D lenses that do not have an aperture ring. nikonusa.com/en/learn-and-explore/article/go35b5yp/… Aug 14, 2016 at 11:19
With regard to the four lenses mentioned in the question the answer is correct. The 50mm f/1.4G and 50mm f/1.8G are AF-S lenses with internal focus motors. The 50mm f/1.4D and 50mm f/1.8D are both AF lenses without internal focus motors that require a body with a built-in focus motor in order to autofocus. Aug 14, 2016 at 11:27
@JamesSnell The answer was also edited to clarify the issues you identified. Aug 15, 2016 at 3:00
The main reason someone would choose a G version of the 50/1.4 over the D version is if you're shooting a D3x00/D40 or D5x00/D60 body, which doesn't have a focus motor in it. On those bodies, the AF D versions do not autofocus, while the AF-S G versions do.
There is also the fact that G versions are typically much newer optical designs, with increased performance. A lot of the G versions are digital-era designs, while some of the D versions are film-era. Sharpness and maximum aperture aren't everything when it comes to lens performance. The G version of the 50/1.4 looks to have better contrast and CA control than the D version when wide open (see: the-digital-picture side-by-side).
When comparing G and D lenses you have to do it on an individual lens basis and not a generalisation regarding each type. e.g. some G lenses do not have a built in autofocus motor and some D lenses do. G lenses include the D distance information. G lenses do not have an aperture ring.
When Nikon changes the designation of a lens sometimes it is improved and sometimes it isn't. Sometimes the autofocus is changed, sometimes the optics are and other times neither.
AF-I and AF-S lenses have an autofocus motor in them whether they G or D. e.g. the AF-S Nikkor 28-70 mm f/2.8 D lens has a motor. The Nikon 28-200mm f/3.5-5.6 AF-G does not have a motor.
Sometimes a D lens can have a better build quality.
All of your examples are rare exceptions to the general rules of Nikon naming conventions. The vast majority of "D" lenses have no in-lens motor. The vast majority of "G" lenses do have an in-lens motor. Mar 8, 2017 at 0:54