But if you can accept the principle of least time (that a light ray will travel along the path that takes the shortest time) then you kind of already accept that (ordinary, classical) light somehow knows the time it takes to go along all possible paths, then chooses the minimum.
The action is a kind of thing, discovered by Hamilton, by analogy, that plays the same role in mechanics as time does in optics. I image he just stared at the equations of optics for a while and had an "ah-ha" moment. He had been working on this stuff for decades, on top of being a pretty smart guy already.
It's extremely unintuitive that classical systems should minimize anything like a time or an action. Think about it: they travel along the minimum path, but how do they know that that path is the minimum? Do they sample the other paths to know?
Well interestingly, Feynman's thesis was about exactly this idea. What happens if you start from the assumption that particles just sample all possible paths (weighted by something having to do with the action/time)? It turns out you can get the Schrodinger equation (and optics equations) from that too. It partially explains how paths "find the minimum." It turns out they don't, but a nice cancellation happens that makes the minimizing path the most probable one.