'Doughboys' was the nickname given to the American Expeditionary Force that took part in the later years of World War I. Before the Americans arrived in Europe, the colloquialism had applied only to infantrymen, but at some point between April 1917 and November 1918, the word expanded to include the whole American armed forces. The term was not used in a derogatory sense and is present in the diaries and letters of US serviceman, as well as newspapers.
Why were the Doughboys there?
The Doughboys helped change the course of the war, because while they were still to arrive in their multi-millions before the war ended, the sheer fact they were coming at all helped keep the western allies intact and fighting in 1917, allowing them to cling on until victories were won in 1918 and the war ended. These victories were, of course, achieved with the aid of the US troops, as well as many soldiers and supporters from outside Europe, like Canadians and Anzac troops (Australia and New Zealand). The western allies had asked for American help since an early stage of the war, but this was initially given in trade and financial support which often gets missed out of histories (David Stevenson's '1914 to 1918' is the best starting point for this). Only when German submarine attacks on US shipping provoked did America join the war, decisively (although the US President has been accused of wanting to bring his nation into the war so he wouldn't be left out of the peace process!).
Where the Term Came From
The actual origin of the term 'Doughboy' is still debated within both US historical and military circles, but it dates back to at least the American-Mexican War of 1846 to 1847. An excellent summary of the theories can be found if you wish to pursue US military history but in short, no one knows for sure. Getting covered in dust while marching so looking doughy seems to be among the best, but cooking practices, uniform style and more have been cited. Indeed, no one knows how the course of World War One gave the term Doughboy to the whole US expeditionary force. However, when US serviceman returned to Europe en masse during the Second World War, the term Doughboy had vanished: these soldiers were now GI's and would be for the next decades. The Doughboy thus became associated forever with World War One, and again no one really knows why.
You may be interested to note that 'doughboy' was also the nickname of an inanimate object, a form of flour-based dumpling that partly developed into the doughnut, and was in use by the late eighteenth century. This might be where the soldier's doughboy name began, transmitted to soldiers, perhaps as a way of initially looking down on them.