Originally, football was a broad term in medieval Europe for any game played on foot with a ball, as opposed to games played on horseback. By the 1800s, two main styles emerged in England: Association Football (focused on kicking) and Rugby Football (which allowed handling and running with the ball).
When these games spread to North America, early versions of American college football resembled Association Football. But by the 1870s, American schools began favoring rugby-style rules. Over time, these rules evolved into American Football, which became the dominant version in the U.S.—hence, it kept the name football.
To distinguish between the types of football, British students created slang terms: “soccer” (from “Association”) and “rugger” (from “Rugby”). Americans adopted soccer from the British to avoid confusion with their own football.
Also the term soccer was widely used in Britain well into the 20th century, but it later fell out of favor, partly due to its association with American usage.