It is the hard truth that there are thousands of persons living in the US illegally. To check this, Congress passed a law on April 1, 1997, to punish people for staying in the US unlawfully, without legal status. Any stay after a valid visa has expired is also included under this. Per the law, one is not allowed to come or return to the US for three or ten years depending on how long the illegal stay in the US was. These temporary bars are generally referred to as three and ten-year bars.
These temporary bars apply to persons who are overseas and try to return to the US. It does not apply to persons who are already in the US who qualify to apply for permanent residence (green card).
The three-year ban is for persons who have spent more than 180 continuous days in the US illegally whereas persons who spent more than one year in the US without a legal status can be barred from coming back to the US for ten years. But you can apply for a waiver if you stayed in the US illegally but now have married a US citizen or permanent resident and the time bar may not apply in such instances.
A significant point is that if you married a US citizen (not a green card holder), you can also adjust your status from undocumented to legal status, regardless of how long you overstayed in the US illegally as long as you came to the US on legal status.
The law also brought a permanent ban to certain persons. Persons who seriously violate US immigration laws can be permanently barred from coming to the US. People who spent a very lengthy unlawful time in the US or who are ordered to be deported can face a permanent ban from entering the US. They become permanently inadmissible to the US when they leave and return or attempt to return to the US illegally without a visa or other valid permission.
If a foreign national does not come back illegally, he/she has to face the ten-year bar as his/her illegal stay was for more than a year. But when he/she ignores this and tries to come back illegally, that is when this permanent bar comes into effect. It is a very strict aspect of immigration law and considering the seriousness of the issue, there is no way out of this permanent bar.
Such persons who face a permanent ban will not be able to adjust their status even if they get married to a US citizen. Though a bit strange, it is clear that you will not be punished as long as you entered legally, overstayed, and married a US citizen without leaving the country. So, legally entering and overstaying is not considered a big mistake if you get married to a US citizen.