The Payment ID is a semi-unique identifier specific for a transaction. Think of it as a shared word between you and a merchant - even though he doesn't know who sent the funds just by looking at the transaction, he will remember you if you mention this secret word. For other people, it looks like a random word and has no special meaning.
When you transfer XMR to an exchange or between exchanges, you need two pieces of information - an address and a payment ID. The address is the address of the Exchange itself, and the Payment ID is the portion that separates you from another user on that exchange. So if you leave off the Payment ID, your transfer will still end up at the exchange, but they won't know who it belongs to.
If you're transferring XMR from an exchange back to your wallet, you really only need the address of your wallet. A payment ID may be required as a failsafe, though. In this case, you may generate your own payment ID using one of the tools listed below.
A payment ID is not required, but certainly can't hurt. Use one of the tools below to generate a Payment ID.
You can quickly generate a Payment ID on the console/terminal using one of the following:
openssl rand -hex 32
head /dev/urandom | sha256sum
python -c "import os;print os.urandom(32).encode('hex')"
python3 -c "import os,hashlib;print(hashlib.sha256(os.urandom(128)).hexdigest())"
- GRC Research has a random hexadecimal string generator at: https://www.grc.com/passwords.htm