The shortest path can be found by drawing the net for the box, then drawing a straight line on the net between the two points. There are two choices: cross an edge of length 1, or cross an edge of length 2. The latter gives the shorter path, whose length is
... d = √(2² + (1+1)²) = 2√2 ≈ 2.828 units
_____
In the diagram, the shorter path is the dashed line. The dotted line path has length √10 ≈ 3.162 units.
___
It appears that the general solution to this sort of problem is that you want to cross the longest edge of the cuboid.