Microwaves are actually lower energy photons than even visible light. So they don't cook because they carry high amounts of energy per photon, to impart to whatever they touch.
They cook for one reason only: they might be lower energy, but water and some other food molecules are electric dipoles (meaning their structure puts distinct positive and negative charges separated at different places in the molecule) and therefore they will rapidly rotate as they try to align themselves with electromagnetic waves across several ranges of microwave frequencies (even though these are not ionising radiations). Microwaves used in ovens typically have frequencies between 900 million and 2.5 billion Hz (cycles per second). That rotation in effect transfers energy to the molecule and its nearby molecules as heat. So a passing microwave of the right frequency can easily transfer its energy to a water molecule, and cause it to rotate quickly or jostle nearby molecules - which translates as being hotter. It can't easily transfer its energy to nitrogen or oxygen molecules in the air, most plastic/ceramic/glass used for food containers, and so on.
And that's what a microwave oven does. It sends a torrent of low energy photons into the cavity, they bounce around, and when they interact with molecules (and their energy is transferred), its very likely to be water, fat and some other molecules which mainly exist in the food. They don't get absorbed by the air, so the air itself isn't heated up. (A bit like how air isn't hot due to visible light travelling through it.)
Apart from perhaps some specialist materials engineered for the purpose, and some low-level absorption, any significant heating of containers, air, etc, only happen because of energy transferred to water in the food, which then warms the air and containers in turn., or evaporates as steam.