It sends a packet to the server, which, if enabled, returns the packet. At each router, a counter in the "ping packet" is decremented, so one can tell how many routers one is going through to reach it.
It is a test of connectivity. Anything under 100mS ping (50mS one way) is "fast". Most of the internet runs between 100-500mS depending on location and provider.
By setting the max hops to 1, 2, 3, etc, one can find all the routers by IP address and name that the packet goes through.
Some servers, routers, and firewalls do not respond to ping requests, as they are a vector for a denial of service attack.