Here is the Walsh diagram depicting all the valence molecular orbitals (a diagram showing how individual molecular orbitals change in energy due to bending around the central atom). Oxygen has 6 valence electrons, so ozone has 18 electrons in total. If we start on the right where ozone would be linear, we can see that all the orbitals up to the $2\pi_\mathrm u$ orbitals (don't worry about why they are named this) are doubly occupied and the two $2\pi_\mathrm u$ orbitals are both singly occupied.
Note: 6a$_1$ and 2b$_1$ have the incorrect sign on the outer p-orbitals.
If we bend the molecule slightly (moving to the left on the diagram), we can see that there is a favorable interaction between the p-type orbitals on the end as well as between the black of the central p-type orbital and the black of the outer p-type orbitals (Someone drew the $\mathrm{6a_1}$ and $\mathrm{2b_1}$ orbitals wrong, flip the central orbital). This lowers the energy of the molecule.
So why doesn't it keep bending? As a good first-order approximation, we can estimate the relative energy of configurations by the highest energy orbital (provided the other orbitals don't change too much). We can see that if we keep bending, the $\mathrm{1a_2}$ orbital and the $\mathrm{4b_2}$ orbital start rising in energy, eventually rising above the $\mathrm{6a_1}$ orbital. Thus too much bending will be unfavorable, and thus ozone prefers a bond angle of around $117^\circ$.
This same diagram can be used for other molecules, such as $\ce{CO2}$. Try using it to figure out why $\ce{CO2}$ is linear.