4 minutes 30 seconds is the standard limit for one side of a 7" record played at 45 rpm. Quality diminishes greatly if longer than six minutes. Since the 45 rpm record was the industry standard for singles and for jukeboxes this placed limitations on the length of recordings.
There's examples of longer singles such as Hey Jude which runs over 7 minutes. But the agreed upon standard was under 4 minutes 30.
To add a bit of data here - there's a website out there called The Billboard Experiment, which collated data taken from the Million Song Dataset.
Taken from that dataset, they produced this chart of average song length by decade since the 1940s (note that the '40s are actually second from the bottom of the chart).
78rpm disc records were in widespread distribution from about 1900 until about 1960, even though microgroove stereo formats in 33 and 45 rpm were invented in the mid 40's. Both formats coexisted in the jukebox market for more than 10 years, so the popular music of that time had to be formatted to the least common denominator to work on both. (IE 3 minutes)
If you want an exact moment in time where the 3 minute single became standard, consider this: Piano rolls (the first form of "recorded" music) had standard dimensions except for the length. The next format, the Edison cylinder record could fit either 2 minutes, or 4 minutes of music, with a separate machine required to play each size. 78 rpm disc records offered a 10 inch 3 minute size, and a 4 minute 12 inch size.
Anecdotally, I've heard a story from an old musician (that I can't verify, old-timers have been known to make things up) that John Phillip Sousa used to play his marches slower in concert, but was forced to significantly speed them up to fit onto a single record. The speeds on the record being what have stuck in popular consciousness ever since.
People are emphasising the physical medium of recordings as an answer to this question, but it's just as attributable to other factors; songs themselves are short as much because of their ability to be played in their entirety as part of the hit parade. Even when people did own recorded music at home in the 40s to 60s, the radio would have been as big a part of how they listened to music. Also you must factor in the cost of recording sessions, and the fact that these songs were often turned out very quickly as part of a 'Tin Pan Alley' tradition of writing. In short, it's more likely to be because anything shorter is considered too short, and ~2:42 is considered enough. Add to that the fact that the shorter it is, the more likely people are to hear it (and remember it), and you have a winning recipe.