F1 can apply for SSN, but they have to have employment before Social Security Administration will issue a number. This is the new rule after 9/11. I have to point out, though, the practice is not consistent everywhere. This is a new rule and its nation-wide implementation takes time.
OPT employment has to relate to your field of study, that is why it is called Optional Pratical Training, which is a continuation of the F1 study. If a computer science major works in a restaurant as a waiter using OPT, then he is in violation of his F1 status. It is the same as working illegally without authorization.
If you have used your OPT to work in fields unrelated to your major of study, then you are in violation. However, since ICE( Immigration ) does not know about this, you *might* be fine. If they found out because, for example, your employer filed I-9 for you and paid social security tax, then I guarantee you that your green card application will be denied.