On a very basic level, imperialism helped contribute to WWI by giving countries the habit of taking what they wanted by force and also building alliances and treaties based on protecting mutual imperial interests. This sense of justification in using the military to protect or further these interests helped to set nations up for a massive conflict like World War I.
One of the more specific ways that it contributed was by setting up many places around the world where the large empires were in competition. To protect themselves, many of these nations agreed to mutual defense treaties or other agreements that only helped to widen the conflict once it began.
One more way it contributed was simply the feeling that some nations had once the conflict began that they could use it as an excuse to broaden their control in a specific region or take or retake territories they wanted.