Maximal coherence and the resource theory of purity