In this post, assume that all the graphs are simple (no loops or multiple edges allowed) for simplicity. I will use the notion of vertex-connectivity:
Definition. A graph $G$ is called $k$-connected, if removal of any fewer than $k$ vertices leaves $G$ connected.
Question. What is the minimal number $f(n,k)$ such that every simple graph $G$ on $n$ vertices and with at least $f(n,k)$ edges is $k$-connected?
For example, for $k=1$ (with 1-connected equivalent to connected) it is a standard exercise to show the following:
If $G$ is a graph on $n$ vertices such that $G$ has at least $\frac{(n-1)(n-2)}{2}+1$ edges, then $G$ must be connected. (for example, see this MSE post for a slight generalization).
There are graphs on $n$ vertices that have $\frac{(n-1)(n-2)}{2}$ edges that are not connected. For example, take the disjoint union of the complete graph $K_{n-1}$ and an isolated vertex.
Thus $f(n,1)$ is $\frac{(n-1)(n-2)}{2}+1$. What about $f(n, 2)$? Is there anything we can say about $f(n, k)$ for a general value of $k$?
The value of $f(n,k)$ is the expected $\binom{n-1}{2} + k$: the same as the number of edges that guarantees a minimum degree of $k$. In a graph with at least $\binom{n-1}{2} + k$ edges, there are at most $n-1 -k$ non-edges.
To prove that this is enough, we prove the contrapositive: suppose that a graph $G$ is not $k$-connected. Then there must be vertices $v,w, x_1, x_2, \dots, x_{k-1}$ such that in $G - \{x_1,x_2, \dots, x_{k-1}\}$, there is no path from $v$ to $w$.
In particular, this means that $vw$ is not an edge, and for every vertex $y \notin \{v, w, x_1, \dots, x_{k-1}\}$, either $vy$ or $yw$ is not an edge. That's $1 + (n-k-1) = n-k$ non-edges total. So this cannot happen if $G$ has at least $\binom{n-1}{2} + k$ edges.
To prove that this number is minimal, consider the graph consisting of $K_{n-1}$ and an $n^{\text{th}}$ vertex adjacent to $k-1$ others. This graph has $\binom{n-1}2+k-1$ edges, but is not $k$-connected, because deleting the $k-1$ neighbors of the last vertex will disconnect it.