The study of the interactions between microorganisms and their environment, including other organisms and abiotic factors.