The most direct way to explain transferring flights in the United States, even if one is continuing on to another country, is that all passengers arriving on international flights in the US must have the legal right to enter the US. Again even changing planes in this context means in some ways “entering” the country. As a result one must be a US citizen or green card holder, or come from a country that is a part of the US Visa Waiver Program and have a valid ESTA, or if your country is not part of this program you must have a standard US Visa.
In reality there is no difference between entering the US for 90 days or just transiting, in both cases you need an ESTA. It currently costs $14 and you can do it online before leaving for the US. If ESTA is not an option, one can go for the full visa. Forms and details can be found on the on the Department of Homeland Security webpage.