There are a zillion lenses out there for you to choose from, manufactured by the main brands as well as third-party vendors.
First thing's first. The lens needs to be compatible with your camera. I can't speak for Cannon, but essentially all Nikon lenses are compatible with every Nikon camera made since the 1960's. The exception is the Nikon D40, which does not have an autofocus screw, so you will have to focus older lenses manually. Still not the end of the world.
The first question to ask yourself is "What exactly am I going to be photographing?" Are you going to be taking lots of portraits? Landscapes? Really small objects? Birds that are really far away? Travel shots? There are lenses that are uniquely suited to each of these applications. Some lenses will do all of these fairly well.
Should I get a prime (fixed focal length) lens or a zoom lens? My first reaction to this is to get a zoom. It provides more flexibility in a lot of situations, and is easier than carrying a plethora of prime lenses with you if you need to cover a wide range of focal lengths. While you can zoom a prime lens with your feet, sometimes this just isn't possible. Nikon's 18-55mm f/3.5-5.6 is a fantastic lens for the price, which is why it comes bundled with the D40 and the D40x. If you want more telephoto capability than that, a good choice is the Nikon 55-200mm f/4-5.6. This great little telephoto can be had for about $200.00, and also has the critical VR (Vibration Reduction) technology.
If I get a telephoto, should I get one with VR (vibration reduction)? If at all possible, yes. VR is a godsend. You can shoot at much slower shutter speeds and get great results. And VR makes it much easier to shoot handheld (without lugging around a tripod).
How fast of a lens do I need? With today's digital cameras that provide good images at high ISO's (up to 3,200), having a fast (wide maximum aperture) lens is less important than it used to be. For fast action photography (sports), low-light photography, or portraits, having a fast lens can be useful. However, the price of a lens increases greatly as the maximum aperture increases. The fastest zoom telephotos (f/2.8) can cost thousands. However, a fast (f/1.8 or less) prime lens in a normal focal length (50mm) can be had for much less.
What about the optical quality? Most lenses that you can buy today have excellent optical quality. The only exception are some of the less-reputable third-party lens manufacturers. For most lenses, differences in optical quaqlity are only apparent when shooting at a test chart in tightly controlled contitions.