Formal Geometry of Differential Equations -- Involution I: Algebraic Theory