As with any sport that was not actually invented by a single person at a given time (like basketball was), the origins of soccer are not completely clear.
We do know that soccer (Association Football) split off from rugby in the 1860s and 1870s. It was at that time that rules for the game of football were being codified. Groups with different traditions formed the Football Association (in England) and the Rugby Football Union.
Before that, the origins of the game are much less clear. There were sports in which balls were kicked in many areas of the world. However, since soccer as we know it originated in England, it is best to look at its history in that country. The game is said to have originated in mass games in which the populations of villages would try to move a ball into the opposing village. These mob games with unlimited numbers of players eventually morphed into soccer.