Evolutionary and functional dynamics of plant immunity