SrTiO$_3$ is a model perovskite compound with unique properties and technological relevance. At 105 K it undergoes a transition from a cubic to a tetragonal phase with characteristic antiferrodistortive rotations of the TiO$_6$ octahedra. Here we study systematically the effect of different exchange correlation functionals on the structural, electronic and optical properties of cubic and tetragonal STO by comparing the recently implemented strongly constrained and appropriately normed (SCAN) meta-GGA functional with the generalized gradient approximation (PBE96 and PBEsol) and the hybrid functional (HSE06). SCAN is found to significantly improve the description of the structural properties, in particular the rotational angle of the tetragonal phase, comparable to HSE06 at a computational cost similar to GGA. The addition of a Hubbard $U$-term (SCAN+$U$, $U=7.45$ eV) allows to achieve the experimental band gap of 3.25 eV with a moderate increase in the lattice constant, whereas within GGA+$U$ the gap is underestimated even for high $U$ values. The effect of the exchange-correlation functional on the optical properties is progressively reduced from 1.5 eV variance in the onset of the spectrum in the independent particle picture to 0.3 eV upon inclusion of many-body effects within the framework of the $GW$ approximation (single-shot $G_0W_0$) and excitonic corrections by solving the Bethe-Salpeter equation (BSE). Moreover, a model BSE approach is shown to reproduce the main features of the optical spectrum at a lower cost compared to $G_0W_0$+BSE. Strong excitonic effects are found in agreement with previous results and their origin is analyzed based on the contributing interband transitions. Last but not least, the effect of the tetragonal distortion on the optical spectrum is discussed and compared to available experimental data.