The total length of the curve described by f is the integral of |df/dt| dt, which is to say, the integral of sqrt((dx/dt)^2 + (dy/dt)^2 + ...) dt. This integrand is at least as large as dx/dt dt. But the integral of this latter integrand is the difference of B's and A's x coordinates, which is to say, the length of the direct straight-line path from A to B.
Thus, every path from A to B is at least as long as the direct straight-line path. [In fact, paying more careful attention, we have by this same argument the slightly stronger result that every other path is strictly longer than the straight-line path]
If you take all of the above for granted (or "obvious"), you may as well say that the straight line being shortest is obvious.
I spelt out the parts of the argument that might be unfamiliar. I'm sure anyone here can readily convince themselves that sqrt(x^2 + y^2) >= x [x^2 is increasing for positive inputs, thus so is its inverse function, so sqrt(x^2 + y^2) >= sqrt(x^2) = |x| >= x], and that you can choose a coordinate system so that A and B are both on the x axis [take A to be the origin; take the vector from A to B to give the positive x axis, and other axes accordingly perpendicular to this one], and so on.
The integral business can be phrased however one likes, formally or informally, to account for the idea of a rectifiable curve as one whose length is given by treating it as built of many component straight-line pieces. The conceptual argument is the same, regardless of any particular choice of technical framework.
And if you furthermore aren't sure that, say, x^2 is increasing on positive inputs, we can explore that as well. If you furthermore aren't sold on modus ponens, we can explore that as well. Everything is infinitely explorable (and malleable!). But I noted only what here seemed directly relevant to the curiosity at hand.
[1] The reason I was satisfied with this is that it's obvious that the speed of the particle is irrelevant to the length of the path so long as the medium is uniform, so once I proved it for light of constant speed, I was done. It's not necessarily satisfying for a mathematician though.
Just spell out what we mean by path, length of a path, and use calculus of a single variable. No need to introduce 'time', 'constant speed' or the like.
BTW, a truly variational proof is in the wikipedia article [0].
[0] https://en.wikipedia.org/wiki/Calculus_of_variations#Example
Well, for starters, it was also posted an hour before that one...
But it's not the same. The sibling comment performs a change of basis. I don't.