In just a few words, PID is an algorithm that makes sure the heaters for both hotend and heatbed supply just enough heat in order to have the difference between the highest and lowest temperature as small as possible.