A CD key is the code printed on the game's disc or packaging that you enter to prove you legitimately purchased the game.
You need a valid key to install and play, so buying the game is required to get one. It's a standard anti-piracy measure, not something you can generate on your own.