The speaker is a soldier. He has been in battle, and, "Ranged as infantry," has shot down another man and killed him. In this poem, the speaker is musing on what has just happened. He reflects that he has shot the other man dead Because he was my foe," but he is not quite comfortable with that reason, and attempts to justify it to himself a little better, saying, "Just so - my foe, of course he was; that's clear enough."
The speaker's motivation is to justify to himself the fact that he has killed a man. He is trying to make sense of it all; to make sense of the fact that, since he and this man had been labeled the enemy and the two had been lined up against each other as foot soldiers, it makes sense that they should shoot at each other, and that one or both of them should die. The logic of this situation does not sit well with the speaker, however, because somewhere deep inside he realizes that the man he killed, like him, had been an ordinary man who had probably enlisted in the military just because he "Was out of work...no other reason why." The speaker knows that if the two men, he and the man he killed, had met in different circumstances, for example "by some ancient inn," they might have been friends and shared a drink together, but because they met in war, they could not but shoot at each other to kill. The speaker is trying to undertand the absurd folly of war; how "quaint and curious war is," that it would dictate whether he would amiably have a drink with another man upon meeting him, or just shoot him down.