one piece of the dog tag remained with the body if found dead and the other was collected for inventory purposes...probably used in some form or another since the early 20th century
Originally, a dog-tag was an identity-device for actual dogs. In 1918, American soldiers started using it as a slang name for the disc they themselves had to wear. Perhaps they felt they were treated no better than dogs?
The explanation is simply that when service personnel (not just the Army) started to wear identity discs they were in the form of those previously worn by dogs. Because they looked the same they just called them the same. Quizmonster is correct about service personnel being treated like dogs ... but that's a different issue.