In Publication 519-A, section Roth IRAs -> Can You Contribute to a Roth IRA? -> What if You Contribute Too Much? -> Withdrawal of excess contributions (here is the one from 2019), it says:
For purposes of determining excess contributions, any contribution
that is withdrawn on or before the due date (including extensions) for
filing your tax return for the year is treated as an amount not
contributed. This treatment only applies if any earnings on the
contributions are also withdrawn. The earnings are considered earned
and received in the year the excess contribution was made.
Based on that, I believe that the earnings would be considered income in the year you made the excess contribution (2020), even though you withdrew it in the beginning of the next year.
However, there may be a better option than withdrawing the contribution. As you may know, even if you are over the income limit for direct contributions to Roth IRA, you can make a "backdoor Roth IRA contribution" (contribute to Traditional IRA and then convert it to Roth IRA), which, assuming you have no pre-tax money in Traditional/SEP/SIMPLE IRAs, accomplishes the same result as a direct Roth IRA contribution, but with no income limits.
However, you originally made a Roth IRA contribution and not a Traditional IRA contribution. So what you can do is "recharacterize" the Roth IRA contribution as a Traditional IRA contribution (basically, it treats it "as if" you had originally made a Traditional IRA contribution all along). And then you can proceed to convert that to Roth IRA, completing the backdoor Roth IRA contribution. So it would be as if you made a Traditional IRA contribution in January 2020 and then converted it to Roth IRA some time in 2021. For the conversion, you will pay tax on the earnings between contribution and conversion (since earnings in Traditional IRA are pre-tax). Remember that this will only work if you do not have any existing pre-tax money in Traditional/SEP/SIMPLE IRAs and will not put any pre-tax money into Traditional/SEP/SIMPLE IRAs in the year of conversion.
In the future, if you are unsure whether you will go over the limit, and you have no money in Traditional/SEP/SIMPLE IRAs, you can always pre-emptively do a backdoor contribution, as there is no downside to doing the backdoor even if you don't need to, other than needing to fill out one additional form on your tax returns.