Cosmological perturbations and structure formation in nonlocal infrared modifications of general relativity