Is it safe that everybody can see the Windows product ID? What is my CD key given the product ID?
Product ID and Product Key are two different things and they have nothing to do with each other. Product ID created upon Windows installation and used for technical support purposes only. It has absolutely nothing similar with a key used for activation.
You can't get activation key if you know Product ID and yes it's safe for other people to see it.
The simple answer is that these are two distinctly different things. This Microsoft KB describes what's happening -
A PID is created after a product is successfully installed. PIDs are used by Microsoft Customer Service to help identify the product when customers engage Microsoft for support. A Product key is a unique combination of numbers and letters that is used during Microsoft software installation to "unlock" or open the product. If you do not enter the product key when you are prompted during the installation, the product may not open until you enter the product key.
Essentially, the Product ID can be tied to hardware, whereas a Product key is tied to software.
It is important to note that PID isn't used only for PCs with Windows OS, but also for mobile devices, gaming consoles, peripherals, etc.