You loop over all enemies i. e. unitIndex will go from 0 to the number of the last enemy
For each enemy, you check the distance.
If the distance it is small, the enemy would be close, if it is large, the enemy is far away.
But which enemie is the farthest?
Well, what you do is:
Stick with one, check the others. if you find one, which is better (farther away) stick with him and drop the previous, you stuck with. You match each enemy against the best one you have. If its better, thats your new best!
In the end, you will keep the one, that has beaten all the others.
That's the farthest!
Ho do you "stick" to an enemy? Your store the enemy itself in furthestUnit. Plus, you store the distance of that (so far best choice) enemy in maxDistance.
And then you compare the distance to all following enemies to your maxDistance
(distanceto >maxDistance) to see, if you should stick with the new one.
But how to start?
You assume, you have an enemy with distance 0 in the beginning. This will result in the first enemy in the list to get the one you stick with first.
When you chose a number like 1 for maxDistance, eventually you will find an enemy who is farther away. From then on, your loop works as intended, i. e. that enemy would be the first you stick with.
With a number like 100, no enemy will be that good, so you get none that is better and your function fails.