If you are a foreign national seeking a green card, and eventually U.S. citizenship, based on marriage to a U.S. citizen or permanent resident, one of the most important requirements is that the marriage be bona fide—that is, not a sham to get a green card. The fact that you and your U.S. spouse are having marital troubles and separate doesn't automatically cause U.S. immigration authorities to believe that you have entered into a sham or fraudulent marriage. But the separation can, depending on timing, make getting a green card difficult, as described below.
We're assuming here that the separation is an actual court-ordered or otherwise written agreement in which you and your spouse have decided to live separately and apart. Simply living in two different places, for other reasons than to put your marriage on hold, is not considered a separation, and should not affect your immigration status—although it could make it harder to convince the immigration authorities that your marriage is ongoing and the real thing.
Obtaining a green card through marriage to a U.S. citizen or lawful permanent resident is a multi-step process, which normally takes several years to complete.
First, the U.S. citizen or resident must file a petition on your behalf (Form I-130). Once that's approved, and if the U.S. spouse is a permanent resident (not a citizen), the foreign national waits, sometimes up to five years, for a visa to become available. (Due to annual limits and high demand, a waiting list often develops.) This particular waiting period isn't a concern for spouses of U.S. citizens, for whom the law sets no limits on visa availability.
Next (or at the same time as the I-130 if the foreign national is already legally in the U.S. or for some other reason eligible to adjust status), the would-be immigrant files an application for a green card. This might be done either in the U.S. (if adjusting status) or through the National Visa Center (NVC) and then an overseas consulate (if coming from abroad).
As the final step in that application process, the would-be immigrant attends an interview. Again, this is either at a U.S. consulate or, if adjusting status, at a U.S. office of U.S. Citizenship and Immigration Services (USCIS).
Assuming all goes well, you will be granted U.S. residence either at your adjustment of status interview or, following your receipt of an immigrant visa from an overseas U.S. consulate, upon entering the United States.
If, however, your marriage is less than two years old at the time you are either approved by USCIS or enter the U.S. on your immigrant visa, you are not granted permanent residence yet. Instead, you receive conditional residence, which expires after two years. Within the 90 days before the expiration date, you and your U.S. spouse must file a joint I-751 petition asking that the conditions be removed and that you be granted permanent residence (which doesn't expire, although you have to get a new card every 10 years).
You can file for U.S. citizenship (naturalization) after having had the green card for five years if your spouse is a permanent resident, or three years if your spouse is a U.S. citizen and you've been both married and living together all that time.
The farther you've gotten in your quest for a green card, the better your ability to overcome a legal separation. Here's what usually happens:
If you have separated and are hoping to obtain a U.S. green card through your marriage, you will absolutely want to get a personal analysis of your situation from an experienced U.S. immigration attorney. The attorney can help you strategize the best path forward, prepare forms on your behalf, draft legal arguments, attend immigration interviews with you (if in the United States), and more.