The withdrawals come from contributions first ... only then do you invade the earnings. You can take out the contributions tax free at any time and they will not be taxable so they are not part of your AGI ... this will not affect the Marketplace insurance. https://www.healthcare.gov/income-and-household-information/income/#magi
jlilya, you said that the distribution came from investment returns. This could only happen if you had already (or concurrently) received distributions of all of your regular contributions and Roth conversions made to Roth IRAs.
If the distribution indeed included amounts attributable to earnings in your Roth IRAs, that amount is taxable and is generally subject to an early-distribution penalty. Being taxable, it adds to your AGI which is used to determine your eligibility for Premium Tax Credits under the ACA.