This paper proposes the robust iterative learning control (ILC) design for uncertain linear systems with time-varying delays and random packet dropouts. The packet dropout is modeled by an arbitrary stochastic sequence satisfying the Bernoulli binary distribution, which renders the ILC system to be stochastic instead of a deterministic one. The main idea of this paper is to transform the ILC design into robust stability for a two-dimensional (2D) stochastic system described by the Roesser model with a delay varying in a range. A delay-dependent stability condition, which can guarantee mean-square asymptotic stability of such a 2D stochastic system, is derived in terms of linear matrix inequalities (LMIs), and formulas can be given for the ILC law design. An example for the injection molding is given to demonstrate the effectiveness of the proposed ILC method.