The evolution of substructure in galaxy, group and cluster haloes - I. Basic dynamics