Most physical units have to be defined in terms of something measurable, and a good definition of a physical unit is one in which the measurement of the unit is very precisely repeatable.
Since prehistory, a day was a very natural way of measuring time, and was highly repeatable, in that the procedure of measuring a day can be performed anywhere on Earth with essentially the same result. The day as a unit then got split into two, for (roughly) sunrise to sunset versus sunset to sunrise, and each half of a day got split into 12 hours. Splitting something into 12 parts was a natural choice at the time, due to the widespread use of a duodecimal (base 12) numbering system in ancient Sumer and India at the time. The later splitting of an hour into 60 minutes, and then later after that splitting a minute into 60 seconds, were natural choices at the time, due to the use in other cultures of sexagesimal (base 60) numbering systems. That definition of a second as being $\frac{1}{24 \times 60 \times 60}$ of a mean solar day was in use from the time it was defined by the Persian scholar al-Biruni 1,016 years ago, until 1967.
However, although measuring time based on the length of a mean solar day was as precisely repeatable of a definition of time units as one could hope for for centuries, astronomical observations in the 1800's and 1900's showed that the duration of the mean solar day wasn't precisely constant, but instead was very gradually getting longer, making the mean solar day a less desirable basis for defining time units. In 1967, the transition time between the two hyperfine levels of the ground state of cesium 133 was about the most precisely repeatable measurements of time that was technologically possible, and certainly more precisely repeatable than measuring the duration of a mean solar day, so in 1967 the definition of a second was changed to be based on cesium 133.
However, redefining the second to be something like 10000000000 of those cesium periods, just because 10000000000 is a "nice" number using modern base 10 numbering, would be a hugely disruptive change for all those people (everybody) who had been using a second as it had been defined for the previous 967 years. To minimize that disruption, the new definition of a second was made to be as close as possible to the same amount of time as the ancient definition of a second.
It's helpful for performing precise calculations to define the second as being an integer number of those cesium 133 periods, and 9192631770 cesium 133 periods was within the range of how long the old second was, i.e., within the experimental error of comparing those two durations as precisely as was technologically possible, so a definition of the second as being precisely 9192631770 of those periods was chosen.
The above history of the definition of a second is slightly oversimplified; see Wikipedia's second article for a more detailed account.