The attorney general sued the state, citing a law allowing New Yorkers to get a driver’s license regardless of legal status.