On residual stresses and homeostasis: An elastic theory of functional adaptation in living matter