Put the leg that best matches your shelf width under the shelf. That is why there's different leg sizes. The bracket's critical section is the inner corner, it is equally strong in both directions. That said, usually the critical portion of the entire assembly is the withdrawal of the upper wall screw. Having the long leg against the wall somewhat reduces this force. But if that results in a significant portion of the shelf unsupported, that could weaken the assembly more than the modest gain in withdrawal strength.
The best approach is to fully support the shelf and use wall screws that are long enough to provide plenty of withdrawal strength regardless which leg is against the wall.