Under the earliest baseball rules laid out by the Knickerbocker club in 1842, there was no set number of innings. Rather, the first team to score 21 "aces"(or runs) was the game's winner. This lasted until 1857, when leading baseball figures held a convention in New York and revanped the rules of baseball, essentially making it the game it still is today. Instead of 21 aces, they decided that games shouuld last a set number of innings. An initial proposal called for seven inning games, but for reasons lost to history, they decided on nine instead - perhaps to match the number of players per team, whiich they also standardized at nine.
Imagine how baseball history might have unfolded if games were 7 innings. No-hitters might triple, four man pitching rotations might still be in vogue, The closer's role would have diminished in importance (top save seasons around 20?), Position players would get about 20% fewer at bats. How different would baseball history be had those 2 innings not been tacked on back in 1857?