A CD key that won't work usually means one of a few things. If it has already been used, it may be registered to another computer, since these keys are single-use. It is also possible the key has been blocked, which can happen if it was obtained outside legitimate channels.
The cleanest solution is to make sure you have a genuine copy with its own unused key. If your legitimate key still fails, contact the seller or publisher for support, or request a refund if the copy is faulty.