69% of the energy density of the Universe today is in the form of a mysterious "dark energy" component which seems to be driving its accelerated expansion. To elucidate the nature of this component, and to assess whether it is compatible with General Relativity, a next generation of experiments is at our doorstep. These experiments use weak distortions of galaxy shapes ("gravitational lensing") as their main probe, and will soon reach an unprecedented high-precision regime. In such regime, accurate modeling of the large-scale structure of the Universe becomes crucial to realize the goal of obtaining unbiased constraints on the cosmological model. I will describe efforts to build and test models of the large-scale structure using a combination of analytical theory, cosmological simulations and existing observational data sets. In particular, I will demonstrate that the incidence of galaxy formation on our interpretation of gravitational lensing observables is significant. Effects such as the impact of Active Galactic Nuclei feedback on the distribution of matter, or tidal correlations between the shapes of galaxies, are starting to play a role in our efforts to constrain cosmology. At the same time, I will show that these effects can also open up new windows into the Universe. Looking ahead to the next decade, I will describe the construction of a robust software pipeline for cosmological model predictions for the Large Synoptic Survey Telescope.