In short, it's easy on the eyes;
'Simply put, contrast is the difference between two colors. On a web page, the amount of contrast required varies with different parts of the page. You usually want a high contrast between text and its background color. But too high contrast between design elements might give an unsettled and messy impression. Black and white create the highest contrast possible.' -Quote from here
This is a great site for UX colour suggestions/examples and theory. And discusses the contrast of different colours on background, even giving the hex code which is quite handy.
Contrast and colour balance is discussed here also.
This also seems to be a style that's trending because the lower contrast between bckgrounds makes the contrast of the text a little nicer(in my opinion) as seen with the colour here and here These samples are more for looking at the colour than their content in terms of what I want to communicate here.
It's not necessarily a rule more of a preference or style. It's more content-dependent than device-dependent. It's about where you want to have the most emphasis or focus - wherever that happens to be is where there should be the most contrast. In the case of StackExchange it's all about questions and answers so the body is where there is most contrast as that is where it is most relevant.
Good luck with your colour choices in future, this is another consideration to take into account :D