When you're seated comfortably, a plumb line dropped from the front of the forward kneecap should touch the end of the crankarm when it's horizontal. Slide the saddle forward or back to achieve this. You need a lot of crotch clearance so you don't hurt yourself if you need to hop off. This isn't as critical for pavement and smooth dirt riding. There's no advantage, however, to riding a frame any larger than the smallest size that provides enough seat height.
Smaller frames are lighter, shorter, and more maneuverable.
Plus, mountain bikes have sloping top tubes that result in relatively short seat tubes. The safest way to determine if a frame fits is to road-test it before buying. Because mountain bike shoes are bulky, toeclips for off-road use run larger than road bike clips. Smoothness is desirable. However, a mountain bike's longer crankarms, combined with riding steeper climbs and rough terrain, contribute to a slower cadence.