According to this site:
In the early days of film cameras were hand cranked, which caused inconsistencies from movie to movie. Even further still, projection houses would speed up frame rates of movies to get that one extra projection at the end of the day. It wouldn’t be until 1929, with the introduction of the optical sound track, that the standard of 24 fps was established. The 24 frames per second standard was the smallest number that was easily divisible by 2, 3, 4, 6, and 8 allowing editors to quickly find where to make their cuts; not to mention was the most cost effective.
However, another site explains it this way:
In this Home Theater Geeks podcast, host Scott Wilkinson talks with
television historian Mark Schubin to find out why. The first
“standard” framerate for filming movies was about 16 frames per
second, although they didn’t measure it in frames per second back
then. The 24fps framerate basically boils down to an off-the-cuff
compromise, as Schubin explains.
According to Schubin, movies weren’t initially measured in frames per
second, but feet of film per minute. As an aside, this is where the
term “footage” came from. 16fps came about because of the “60 feet per
minute” standard. Filming was done at a rate of 60 feet per minute
which provided around 16 frames of movie per second.
While filming was done at 60 feet per minute, playback was often
anywhere between about 80-100 feet per minute (about 20-28 frames per
second). This was in order to speed up the film. It allowed the
theatre to be able to play more movies per day, and get more paying
customers through the door.
When movies started to add sound, though, problems arose. The theatres
were still able to play at pretty much any framerate they wanted to.
But, 16fps movies sped up to 28fps would have actors sounding like
Alvin and the Chipmunks. So, a new standard must be set.
Schubin says that an engineer from Western Electric named Stanley
Watkins went to meet with the Warner Brothers chief projectionist,
Frank Rich. Watkins asked Rich, “What rate do people show movies at?”.
The answer showed quite a range.
The major first showings of movies typically played back at around 80
feet per minute (around 21.5fps). The little theatres that wanted to
get more shows in would play back anywhere up to 100 feet per minute
(about 27fps). Watkins thought for a minute and said “Ok, let’s
compromise on 90 [feet per minute]”.
This second story seems to be supported by this blog post, which offers some more details:
Anyway, someone decided it would be a great idea to add sound. How hard could it be? In fact, several companies tried to be the first to bring sound to the movies, hoping to capture the market. Funny thing is they all insisted on capturing at the same frame rate they displayed at. If you didn’t, the pitch would be all wrong and everybody would sound silly. And forget about music. Some picked 80 feet per minute (the already established speed for projection), some picked 85 feet per minute, and some picked 90 feet per minute. First one to get a working system was Warner Brothers Vitaphone. It was used in the 1927 “The Jazz Singer” which was the first feature length film with sync dialog and is considered the official start of the “Talkies.”
The Vitaphone engineers had picked 90 feet per minute, or 24fps as their capture and projection speed. If one of the others had been first, we easily could be shooting 21.33fps or 22.66fp as a standard today. So sometimes you get lucky.
[...]
Movietone, which used technology that put the audio as an optical track on the film had many advantages, but it was a little late out of the gate. Because Vitaphone was first, the engineers of Movietone decided to match the Vitaphone frame rate.