The cluster Terzan 5 as a remnant of a primordial building block of the Galactic bulge