[Disclaimer: Throughout this post I will be bracketing the ideas of general relativity because I think they needlessly complicate the story.]
The invariance of the speed of the light is more of a statement about the geometry of the universe than it is a statement about light.
Suppose I am in an inertial frame $S$ with coordinates $(t,x,y,z)$. If one event (call it event A) takes place at location $(x_A, y_A, z_A)$ and time $t_A$ in $S$ and another event (event B) takes place at location $(x_B, y_B, z_B)$ and time $t_B$ in $S$, we can consider the quantity
$$
(\Delta s_\alpha)^2 \equiv \alpha (t_A - t_B)^2 - (x_A - x_B)^2 - (y_A - y_B)^2 - (z_A - z_B)^2 \tag{1}
$$
which I will abbreviate as
$$
(\Delta s_\alpha)^2 \equiv \alpha (\Delta t)^2 - (\Delta x)^2 - (\Delta y)^2 - (\Delta z)^2 \tag{2}
$$
Note that the $\alpha$ prefactor must be there because time and position do not have the same units. It is our conversion factor between time and space.
If I shift to another inertial frame $S'$ with coordinates $(t', x', y', z')$ where event $A$ has coordinates $(t'_A, x'_A, y'_A, z'_A)$ and event $B$ has coordinates $(t'_B, x'_B, y'_B, z'_B)$, I can compute $(\Delta s'_\alpha)^2$ just like I computed $(\Delta s_\alpha)^2$ in (1).
How are $(\Delta s'_\alpha)^2$ and $(\Delta s_\alpha )^2$ related? We have
$$
(\Delta s_\alpha)^2 - (\Delta s_\alpha ')^2 = \alpha \left[(\Delta t)^2 - (\Delta t ')^2 \right] - (\Delta x - \Delta x')^2 - (\Delta y - \Delta y')^2 - (\Delta z- \Delta z')^2 \tag{3}
$$
It is an experimental fact that $(\Delta t)^2 - (\Delta t')^2$ is not always zero. In other words, the time difference I measure between two events is not necessarily the same in all inertial reference frames. Suppose we are in a situation where $(\Delta t)^2 \neq (\Delta t')^2$. We see that there is a unique value for $\alpha$, call it $\alpha_0 (A,B,S,S')$, such that the LHS of (3) is $0$, i.e.
$$
(\Delta s_{\alpha_0(A,B,S,S')})^2 = (\Delta s_{\alpha_0(A,B,S,S')}')^2
$$
This notation is chosen to remind us that $\alpha_0$ could depend on our choice of event $A$, event $B$, inertial frame $S$, or inertial frame $S'$.
However, it is an experimental fact that $\alpha_0$ does not depend on our choices of events or inertial reference frames. In other words, there is a dimensionful quantity $\alpha_0$ such that, for any two events, $(\Delta s_{\alpha_0})^2$ is the same in every inertial reference frame.
I want to pause here and emphasize that we have only asked that observers can agree about what constitutes an inertial reference frame and are capable of measuring position and time in their own reference frames. The experimentally verified existence of an $\alpha_0$ with the aforementioned properties is a purely geometrical fact. It tells us how space and time relate in inertial reference frames. We haven't said anything about speed or light. In principle (although this is emphatically not how it happened in actual physics history) we could have observed the existence of this $\alpha_0$ with nothing more than stopwatches and meter sticks.
Now, you are probably wondering what this $\alpha_0$ is. How should we interpret it? To aid in our discussion, we'll switch to writing $(\Delta s)^2$ instead of the nonstandard and unwieldy $(\Delta s_{\alpha_0})^2$. In physics, $(\Delta s)^2$ is known as the "spacetime interval" or simply the "interval" between two events.
To start our investigation, let's consider a pair of events A and B with $(\Delta s)^2 = 0$ (Such a pair exists. Consider A $= (0, 0, 0, 0)$ and B $= (1, \sqrt{|\alpha_0|}, 0, 0)$). This means
$$
0 = \alpha_0(\Delta t)^2 - (\Delta x)^2 - (\Delta y)^2 - (\Delta z)^2
$$
Rearranging:
$$
\alpha_0 = \frac{(\Delta x)^2 + (\Delta y)^2 + (\Delta z)^2}{(\Delta t)^2}
$$
The top of this fraction we recognize as the squared distance between events A and B, which we will write as $d_{AB}^2$. The bottom of this fraction is, of course, the square of the time that passes between event A and event B, for which we'll write $t_{AB}^2$. Then
$$
\alpha_0 = \frac{d_{AB}^2}{t_{AB}^2} = \left(\frac{d_{AB}}{t_{AB}} \right)^2
$$
From this we see that $\alpha_0$ is nonnegative. Thus, we are free to pick a nonnegative $c$ such that $\alpha_0 = c^2$. It immediately follows that
$$
c = \frac{d_{AB}}{t_{AB}}
$$
for events A and B with interval $0$. The interpretation of $c$ is clear. An object which moves uniformly from an event A to an event B separated by a spacetime interval of $0$ travels at speed $c$. In other words, $c$ is how fast you have to move to get between events that have $0$ spacetime interval. Moreover, because of how it is defined, $c$ is invariant: every observer in every reference frame agrees on how fast $c$ is.
You have probably guessed that $c$ is the speed of light. But, again, notice that we defined $c$ completely in terms of the geometry of spacetime. It just so happens that the speed of light, i.e. how fast photons move through a vacuum, is equal to this geometric constant which describes how fast you have to move to get between events separated by a spacetime interval of $0$.
To demonstrate that this is the $c$ we all know and love, I'll argue on geometric grounds that $c$ is as fast as ordinary matter can go. Suppose I want to get from event A to event B. Let's say that in frame $S$ they are time $t > 0$ (I can't teleport, and I certainly can't move backward through time) and distance $d$ apart, so that I must travel at speed $v = d/t$ in $S$ to complete my trip.
In the inertial frame $S'$ whose origin moves with the same velocity as me, we'll measure $x_A' = x_B'$, $y_A' = y_B'$, and $z_A' = z_B'$. In other words, in $S'$ I appear to get from event $A$ to event $B$ by standing still. What can we say about the interval between $A$ and $B$? Calculating in $S'$, we find
$$
(\Delta s)^2 = c^2 (\Delta t')^2 - 0^2 - 0^2 - 0^2 = c^2 (\Delta t')^2 > 0
$$
But the interval is invariant, so in $S$ we must also find $(\Delta s)^2 > 0$. On the other hand, in $S$ we calculate
$$
(\Delta s)^2 = c^2 t^2 - d^2
$$
Thus
$$
c^2 t^2 - d^2 > 0
$$
which means
$$
v^2 = \frac{d^2}{t^2} < c^2
$$
Therefore $v < c$. I can move no faster than $c$.
In conclusion, experiments tell us the geometry of spacetime. If our universe has the geometry that our experiments indicate, then there must be an invariant cosmic speed limit $c$. Based on experimental evidence and theoretical developments, we think this speed limit happens to be precisely the speed at which light propagates.