I imagine there was a significant anti-British sentiment in the early US around the time of the Revolutionary War, which probably lasted until well afterwards. What happened to relations afterwards to make them as favourable as they are today?
Throughout the 1800s, the USA and those within aspired to become one of the great powers of the modern world, among the likes of France, Prussia, Britain and Russia. There are various points where historians say the States finally became a nation with real international clout - be it 1847, 1865, or 1918 - but throughout this period of improvement, industrialization, and immigration, they found themselves at odds with the other great powers. This includes Britain, who the USA was again at war with from 1812 through 1823.
The 'balance of power' philosophy was that none of the aforementioned great powers of the world should be allowed too much power. Essentially, it was a game of global checks and balances. Relations between countries could spin on a dime. You'll find historically that Britain and France were the two greatest rivals of the world, with relations only getting worse when each got the lion's share of the Scramble for Africa in the waning years of the 1800s, and yet by 1914 they were officially allies in an attempt to counter the alliance of great powers Germany and Austria-Hungary. This is one outstanding example of the balance of power bringing two countries together; the U.S. would later join that power bloc, throwing their weight staunchly to the side of the UK - and would do so a second time in 30 years.
Another thing to think about is time. In the 40s, anti-Nazi propaganda was able to effectively convince a large proportion of the American people that most Germans living in Germany were evil racists, but nowadays those opinions are completely gone. That's because the Second World War was 70 years ago, and people today have rightfully discarded those opinions. The distance between 1823 - the last time Britain and the U.S. were in direct conflict - and the present day is nearly 200 years. That is far more than enough time for the two nations to lose the grudge which was held between them, especially with other events bringing them together along the way.
In the late 1800s, Britain was slowly acquiring its vast tracts of African land and increasing exploits in India, and the United States was rapidly industrializing. Trade between the two nations, as well as other great powers who were aligned with them, was vital to the survival of all. That trade was another factor in fostering friendship between the Americans and the British.
TL;DR - trade, international politics, and military alliances, among other friendly things.