Why does this circuit work with no ground?

Current goes from +5 to the LED to the resistor to the pin to 0volts.
Therefore you have a complete path for current flow.