Magnetic monopoles and cosmology