Relative homological algebra, equivariant de Rham theory, and Koszul duality