It's a script to get the nearest GameObject with the tag "Enemy". It initially sets the nearestDistance to Mathf.Infinity so it will consider all the GameObjects in the scene.
If you have an actionRadious for example, you might want to initially set the nearestDistance to the radious so the algorithm does not consider GameObjects farther than that.
The trick is in if(distance < nearestDistance). If the GameObject is farther than the nearest distance encountered so far, it won't take it into account.