Let's call this maximal dimension function $\rho_{\mathbb{Q}}:\mathbb{N}\to\mathbb{N}$, i.e., $\rho_{\mathbb{Q}}(n)$ is the largest possible dimension of a subspace $N\subset M_n(\mathbb{Q})$ such that all of the nonzero elements of $N$ are invertible.
Then $\rho_{\mathbb{Q}}(n)\ge n$, as the following construction shows: Let $p(x)\in\mathbb{Q}[x]$ be a polynomial of degree $n$ that is irreducible over $\mathbb{Q}$, and let $A\in M_n(\mathbb{Q})$ be a matrix whose characteristic polynomial is $p$. (Such $A$ are easily constructed.) Let $N\subset M_n(\mathbb{Q})$ be the $\mathbb{Q}$-subspace spanned by the powers of $A$. Then $N$ is an $n$-dimensional over $\mathbb{Q}$ and $N$ is a field isomorphic to $\mathbb{Q}[x]/\bigl(p(x)\bigr)$, so every non-zero element of $N$ is invertible.
Meanwhile, it's easy to see that $\rho_{\mathbb{Q}}(2)\le 2$, since any $3$-dimensional subspace of $M_2(\mathbb{Q})$ contains a nonzero element with vanishing determinant. Thus, $\rho_{\mathbb{Q}}(2) = 2$. Moreover, as Fedor points out in his comment below, this observation extends to all $n$ because, if $N\subset M_n(\mathbb{Q})$ had dimension greater than $n$ over $\mathbb{Q}$, then $N$ would have to intersect the codimension $n$ subspace of $M_n(\mathbb{Q})$ consisting of those matrices with first column equal to $0$. Thus, $\rho_\mathbb{Q}(n)=n$ for all $n$.