On the differential structure of metric measure spaces and applications