In many ways, it was luck that enabled the Allies to win the war, but they did make make slightly better strategic decisions, while the Germans made some fatal blunders.
The first blunder was to assume that they would win this war quickly, within a few months, as they had the Franco-Prussian war in 1870. As a result, troops were taken from amongst the farmworkers, and no provision was made for planting new crops. When the war bogged down into the misery of trench warfare that it became, crops weren't planted, and the food supply dwindled.
The British made the good strategic move, in contrast, of blockading the German ports. These effective blockades meant that the German people, by 1916, were literally starving—hunger effected even the upper classes. This set the public against the war effort.
Meanwhile, the Germans blundered badly in using their subs to attack a few American ships and by engaging in a plot with the Mexicans against the United States. This turned US sentiments against the Germans so that the US entered the war on the side of the Allies. This was exactly what the Germans most dreaded, and it meant that the Allies would win. England and France were beyond spent out by the time the US entered the war—the British were simply printing money to buy arms, leading to massive inflation—but the US brought in an infusion of new troops and especially supplies to the Allies.
Even with all this, the Germans probably would have held out for a better settlement, but then the Russian Revolution erupted. Communism took over in Russia, and the newly emboldened communists in Germany tried to take advantage of the bad situation in Germany—hunger, high casualties, and people fed up with corruption and war—to stage a revolution there. This was almost successful and added to the weakness of the government, leading to the Germans to abruptly sue for peace.
Neither side planned well for this war. Everyone thought it would be over fast. The leadership of every country badly bungled the war effort, leading to horribly high casualties. However, the German Axis bungled the war more badly than the Allies. They did not have the good fortune to get the US on their side (they bungled that too). They were faced with high levels of unrest and possible revolution at home. All of this allowed the Allies to squeak out a victory that nobody was very happy with, given the cost and the consequences.