The story
The phrase possibly comes from adjusting a sighting mechanism of a firearm to minimise the discrepancy between where the sight points and where a bullet lands on a target. Another possible source is the Cartesian coordinate system in mathematics. In the coordinate system, points are defined relative to an origin (point of reference) labeled O, which has an (x,y) coordinate pair of (0,0).
Etymology from Wiktionary, CC BY-SA 4.0.