Invariant theory for maximum likelihood estimation