There are several ways to obtain a work permit. One is if you have an application pending with immigration, for example: Asylum, TPS, Nacara, Adjustment of Status, etc. Another is if you are going to court as explained in the paragraph below.
Sometimes you go to court to ask for legalization, sometimes because the government wants to be taken out of the country. There are different types of remedies for these problems. Some of the defenses can be for time, asylum, family or work petition, pardons, U visa, S visa, VAWA, etc.
Residence for Work:
If you are indispensable in your job, your employer can request it. It is a long process that depends on the type of work, study and experience you have.
There are many kinds of forgiveness, some are to be able to become a permanent resident, such as I-601A (provisional pardon) to avoid having to wait outside the country for 3 to 10 years. Others are not to lose residence because of having convictions in criminal court.
If you are a resident you can only ask your wife and children. If you are a citizen you can ask for a wife, children, parents and siblings. See graphs below to determine the waiting time for an available visa.
Victims of Domestic Violence (VAWA)
Victims of domestic violence that are children, parents, spouses or ex-spouses of a US citizen or of a permanent resident who are abused by them may be eligible to apply for Permanent Resident status. This provision of the law was created under the Violence Against Women Act.
Every year people come to the United States seeking protection because they have suffered persecution or because they fear they will suffer persecution because of their: Race / Religion / Nationality / Membership in a particular social group / Political opinion / discrimination based on sexual orientation / etc.
If your case was denied you will receive a notice explaining why the decision was negative and whether you can file an appeal. You can also, with certain exceptions, make motions to reopen or reconsider decisions made in your case.