Football was invented around 1876 by a man by the name of Walter Camp. He got the idea from William Ebb Ellis who was playing a game of soccer when he picked up the ball and started to run with it, therefore breaking the rules and giving Camp the idea for the game.
Rugby (started in England, 1823) was introduced to North America by the British Army in Montreal in 1868, which played a series of games with McGill University.
In 1874, McGill arranged to play a few games at Harvard, which liked the new game so much that it became a feature of the Ivy League.
Both the Canadian and American games evolved separately from this point into American and Canadian football.