The length and diameter (2X, 3X......7X) of your leader line depends on the size of fly and type of fishing you are doing. Generally speaking, the larger the fly, the larger the diameter of line needed. Some brands such as Orvis have a chart on the back of the packaging that cross reference fly sizes to the diameter of line needed.
As far as length goes, the longer leaders are often employed to prevent spooking wary fish. The fly will "turn over" softer and more gradually because the change in diameter of the line is spread out over a longer distance. Shorter leaders will tend to turn over quicker for the the opposite reason.
If you are casting tiny flys such as trico spinners to wary trout in clear water, long small diameter (7X) leaders are recommended. If you are casting larger flyes with a sink tip line to bass on the edge of weed beds, a shorter larger diameter leader may be in order.
These are just my own observations and experience. However, I am certainly a novice as compared to some of the other gentlemen that frequent this site, so please heed their advice as well.