This thesis is dedicated to the study of various aspects of the electronic structure of two-dimensional transition metal dichalcogenides (TMDs) of chemical composition MX$_2$ (where M is a transition metal atom and X= S, Se, Te), using a combination of \textit{ab inito} density-functional methods. We first address the relative stability of the $1T$ and $1H$ phases of two-dimensional TMDs as a function of the column of the transition metal atom in the periodic table. Using a Wannier-function approach, we calculate crystal field and ligand field parameters for a broad range of members of this family of materials. Taking TaS$_2$ as an example, we show how the splitting of the $d$ electron states arises from an interplay of electrostatic effects and hybridization with the ligands' $s$, $p$ and $d$ states. We show that the ligand field alone cannot explain the stabilization of the $1H$ polymorph for $d^1$ and $d^2$ TMDs, and that band structure effects are dominant. We present trends of the calculated parameters across the periodic table, and argue that these allow developing simple chemical intuition. Secondly, we study the occurrence of charge density wave phases and periodic lattice distortion in metallic $1T$ transition metal dichalcogenides. The phonon dispersion and fermiology of representative examples with different $d$ electron counts are studied as a function of doping. Two qualitatively different behaviours are found as a function of the filling of the $t_{2g}$ subshell. We argue that away from half-filling, weak-coupling nesting arguments are a useful starting point for understanding, whereas closer to half-filling a strong-coupling real-space picture is more correct. Using Wannier functions, it is shown that strong metal-metal bonds are formed and that simple bond-counting arguments apply. Thirdly, the recently synthesized $1T$ phase of NbSe$_2$, in monolayer form, is investigated from first principles. We find that $1T$-NbSe$_2$ is unstable towards the formation of an incommensurate charge density wave phase, whose periodicity can be understood from the Fermi surface topology. We investigate different scenarios for the experimentally observed superlattice and insulating behaviour, and conclude that the star-of-David phase is the most stable commensurate charge density wave phase. We study the electronic properties of the star-of-David phase at various levels of theory and confirm its Mott insulating character, as speculated and in analogy with TaS$_2$. The Heisenberg exchange couplings are found to be ferromagnetic, which suggests a parallel with the so-called flat-band ferromagnetism in certain multiband Hubbard models. Finally, we address the possibility of the occurrence of the excitonic insulator phase in single-layer TiSe$_2$. The relative role of electron-electron and electron-phonon interactions in driving the charge density wave in layered and two-dimensional TiSe$_2$ has been disputed and is still unresolved. We calculate the electronic structure and finite-momentum exciton spectrum from hybrid density functional theory. We find that in a certain range of parameters, excitonic effects are strong and the material is close to a pure excitonic insulator instability. A possible necessary condition for the physical realization of a pure excitonic insulator is proposed.