This is the Dirac notation. In Quantum Mechanics states of a system are unit rays on a Hilbert space - a special kind of vector space with inner product. In turn, they can be characterized by unit vectors in this vector space. It is usual to denote such a state vector as something like $|\psi\rangle$.
If $|\chi\rangle$ is another state vector, the inner product in the Hilbert space is denoted $\langle \chi |\psi\rangle$.
In turn, we can have bases. An orthonormal basis here is a set of vectors $|\phi_n\rangle$ such that $$\langle \phi_n|\phi_m\rangle=\delta_{nm}.$$
The basis must be complete in the sense that if $|\chi\rangle$ is orthogonal to all $|\phi_n\rangle$, i.e., $\langle \phi_n | \chi\rangle=0$ then $|\chi\rangle=0$.
Now, when we need an infinite set of such $|\phi_n\rangle$ to form a complete set, the Hilbert space is infinite dimensional. When we have a complete set with a finite number $D$ of vectors, the Hilbert space has dimension $D$.
In particular, we can have a $2$-dimensional Hilbert space with a basis $\{|0\rangle,|1\rangle\}$. This is just notation, we could have written $\{|\phi_1\rangle,|\phi_2\rangle\}$. One concrete example of this in nature would be the description of the spin degrees of freedom of a non-relativistic spin $1/2$ particle like the electron.
Now one arbitrary state $|\psi\rangle$ can be written as
$$|\psi\rangle = a |0\rangle + b|1\rangle.$$
Furthermore, we normalize states as I already said, so that we require $\langle \psi|\psi\rangle = 1$, this means that upon using orthonormality of the basis:
$$|a|^2+|b|^2=1.$$
This in turn means that $a = e^{i\phi_1}\cos\theta$ and $b=e^{i\phi_2}\sin\theta$ for some $\phi_1,\phi_2,\theta$. We can choose $\phi_1=0$ though. To prove this, notice that since $|\psi\rangle$ must have unit norm, we can multiply it by any phase $e^{i\phi}$ and represent the same physical state. Thus we exchange $|\psi\rangle$ by $e^{-i\phi_1}|\psi\rangle$. This makes the state become
$$|\psi\rangle = \cos\theta |0\rangle + e^{i\phi}\sin\theta|1\rangle.$$
That is the reason the state can always be written like this.