As I understand, if he resigned as PM he would in effect concede the government and it would be up to the Tories to form a minority or coalition government. Instead he is resigning as Labour leader (effective September) so his party can form a coalition government with Lib Dems. Evidently, he is even remaining PM under the new government, but only until a new Labour leader is chosen.