The soldier is a Union spy. He is taking a big risk riding around in enemy territory in a Confederate uniform. He could be hanged as a spy himself. He waits until after nightfall to repass Farquhar's plantation because he didn't want to be seen heading north in his gray uniform. Ambrose Bierce does not make too big a point of the fact that the soldier is wearing a Confederate uniform. In Part 2 he writes:
...a gray-clad soldier rode up to the gate and asked for a drink of water.
Bierce assumes that everybody knows the Union soldiers wore blue and the Confederates wore gray. The soldier tells Farquhar nothing about where he is going and what unit he is attached to. We do not know whether he is an officer or an enlisted man. He may not be wearing a full Confederate uniform but only gray trousers and a gray jacket. Not all Confederate soldiers had full uniforms. The last sentence of Part 2 reads:
He was a Federal scout.
It does not seem that this soldier was out for the purpose of tempting Southern civilians to try to burn down the Owl Creek Bridge. If the Union officers want to protect the bridge, they have plenty of soldiers for that purpose. They don't have to send out agents to solicit Southern sympathizers to come and burn the bridge down. They have enough problems on their hands fighting the Confederate army without inciting the civilians too. As a "scout" the soldier was probably doing what scouts usually do. They try to find where enemy soldiers are quartered, how many of them there are, and what sort of defenses they have prepared. The spy is headed back north to report whatever information he has managed to obtain in the time he has been away. His stopping for a drink of water on Farquhar's plantation may have had no other motive than to get a drink of water. It was Farquhar who started asking questions about the Yankees. If Farquhar hadn't questioned the scout, the whole subject of the bridge might never have come up. The scout did not want to appear too forthcoming with information because that could arouse suspicion. But when the scout realized that Farquhar apparently was planning to sabotage the bridge, he naturally would have reported that information to his superiors.
When a "gray clad" soldier passes the entrance to Peyton Farquhar's property one evening asking for a drink of water, Farquhar's wife is "only too happy to serve him with her own white hands." Farquhar is glad to see the Confederate soldier as well, striking up a conversation with him and inquiring about "news from the front." The Yankees are on the move and heading south, the soldier tells Farquhar. Union soldiers have occupied the Owl Creek bridge about thirty miles away, the rebel says, but their force is not strong. Trusting the soldier, Farquhar inquires about the likelihood of destroying the bridge, and the soldier tells him that it might be possible. The soldier finishes his water and heads south, presumably toward the Confederate lines. Later that night, under cover of darkness,
... he repassed the plantation, going northward in the direction from which he had come. He was a Federal scout.
The soldier is heading to the north because he is a Union spy, dressed in Confederate clothing. He is probably heading back to his lines--possibly those at the Owl Creek bridge--to report that he has successfully made contact with Farquhar and supplied him with false information. The narrator suggests that Farquhar has spied before: There were "Circumstances of an imperious nature" and that there was "no adventure too perilous to undertake." Farquhar may well have been previously suspected of spying, and the Federal scout had orders to set him up.