There are two main sources for the common time signatures in music of "Western" music (i.e., the legacy of composition and theory coming from Europe via the baroque, classical, romantic, etc., periods): War and dance.
Without spending too much time on historical details, from war we get the idea of marching music and march time signatures, which focus on having two beats (to match our two legs). For reasons I don't know, dance gave us waltz time with three beats, and uhhh.. some other dance style time with four beats.
So the most common numbers of beats in all of (Western) music are 2, 3, and 4, with 4 being the most common of those.
Again for reasons I won't get into (mainly because I don't know them), in terms of note values, Western music has gravitated towards the quarter note (crochet) as the basic note value to start from. So it clearly follows that if we want to divide all of our beats into groups of 2, 3, or 4, we would create groupings (measures) of 2 quarter notes, 3 quarter notes, and 4 quarter notes. We call those 2/4, 3/4, and 4/4 time.
That might not be news to you at all. What took me a long time to figure out is that pretty much, all other time signatures are somehow descended from those three - either by direct interbreeding or mutation or both.
Western meters and rhythms are primarily duple, meaning we like to divide things in half. That's why from the quarter note, we can cut it in half to eight notes (quavers), sixteenth notes (semiquavers), and so on. Sometimes, however, we like to divide things in threes. 3/4 is of course a measure divided in three. If we want to keep dividing in threes we could use triplets, but that gets tedious quickly if the whole piece is divided in threes. A dotted quarter note divides easily into three eighth notes, so that's a solution, but how do we write down a time signature of 2, 3, or 4 dotted quarter notes? 2/4.5 time? That's gonna confused people at best.
But what if we leave behind the quarter note and instead take groups of three eighth notes. Then 2/4 time could be turned into 6/8 time. That's 2 beats of 3 eighth notes each, for a total of 6 eighth notes. And likewise with 3/4 turning into 9/8 and 4/4 turning into 12/8.
So 6/8, 9/8 and 12/8 are just 2/4, 3/4, and 4/4 divided in threes instead of twos. Those time signatures are called compound time.
As composers and songwriters started to get more creative and wanting to push boundaries, these three time signatures and their three compound flavors started to seem limiting. And maybe boring. The two most common mutations (in my experience) of these time signatures are both based on 4/4 time. The first is to extend the 4/4 measure by an extra beat. And that gives us 5/4 time. You've heard that a bit I'm sure since the Mission Impossible theme and the main riff from "My Wave" by Soundgarden are both in 5/4 time. Another very popular one is 7/8 time, which is just a 4/4 measure that ends slightly early by an eighth note. There are 7/8 measures peppered into "My Wave" during transitions, but if you really want to hear 7/8 in action you might check out "March of Pigs" by Nine Inch Nails which has a verse pattern of three 7/8 measures followed by one 4/4 measure. Or you could check out something less aggressive in the form of "The Ocean" by Led Zeppelin, which has a verse riff that is three 4/4 measures followed by one 7/8 measure and then the patter repeats. You can feel the "shortness" of the turnaround on that riff pretty easily (Bonham sure did cut some deep, deep grooves).
So that's pretty much it for 95% of the time signatures you're ever going to see (unless you really go in for certain genres where more esoteric time signatures are popular). You've got 2/4, 3/4, 4/4, their compound versions, and then a smattering of mutations.
As to why we have time signatures at all, there are several reasons, and I think there are other questions and answers on this very site that delve into them. I'll briefly mention two bigs ones. First, there has to be some way to organize music in time. You might as well ask why have distinct notes when the human voice and many other instruments can make any pitch in between C and C# (for example). Well we have to divide it up somehow or else we can't get a grip on it. Imagine if you're rehearsing a whole symphony and the conductor says, "go to the part with the B major chord that's about seven minutes and forty-two seconds in from the beginning" instead of just "now we're going to measure 78".
The second reason is that time signatures do imply stresses on the beats 2/4 is strong weak, strong weak. 3/4 is strong weak weak, strong weak weak. 4/4 is strong weak medium weak, strong weak medium weak. That's how you can tell the difference between 5/4 and 2/4 and 3/4 alternating.
Hopefully that helps you get a grip on time signatures. The best way to understand them fully is to read and learn to play a wide variety of music. After a bit of time, you'll be feeling the time signatures without even thinking about it.