When was American football invented and who invented it?

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.

American Football was not invented. It evolved over a period of time, from 1874, for at over 30 years. Many people contributed to its development. Though Walter Camp is called the Father of American Football, this was because he promoted it and was prominent on rules committees in its early years, not because he invented it.

The game played by McGill and Harvard might not be recognized as football by a modern audience. For example, it did not permit forward passes, and did not have a line of scrimmage. These developed during the 1880s and 1890s. The flying wedge formation was introduced in 1892 and banned because it was deadly in 1894. But football remained so brutal that in Theodore Roosevelt (of all people) threatened to close it down unless rules supporting safety were adopted. The forward pass was one of the resulting improvements, and is so important to the modern game that it is hard to imagine football without it.