When you buy the game, the registration code is normally printed on the back of the manual or on a sticker on the case insert.
If you have lost the physical copy, contact the publisher's support with proof of purchase — they can sometimes reissue it. Codes sourced elsewhere are usually invalid or already used.