Cosmic evolution of the interstellar medium density and its role in hiding early supermassive black holes