We know that any object above absolute zero emits electromagnetic radiation. The hotter the object, the shorter the wavelengths. In the electromagnetic radiation spectrum, radio waves have the longest wavelength, then microwaves, then infrared, then visible light, then ultraviolet, then x-rays and gamma rays. Why do we use microwaves in microwave oven when infrared and visible light are much more energetic, and how do microwaves cook food when they are less energetic than visible light and others?
In microwave ovens what matters is how much energy the radiation carries and how that energy is absorbed by the food. Visible light and IR are rapidly absorbed by most foods, so they would only heat the outer layer of the food. You'd get food with the outside carbonised and the inside raw.
Microwaves are far less strongly absorbed by foods, so they penetrate deep into the food and can heat the interior. Even so large objects won't be heated throughout, which is one reason why microwave cooking instructions frequently advise a multi stage process of heating, letting the food stand then heating a final time.
Microwave ovens often include IR heating as well as the microwave heating. This is done so you get food with a browned exterior and heated throughout.
The answers to Why do microwave ovens use radiation with such long wavelength? give a nice discussion of why the exact wavelength used was chosen. The frequencies commonly used in microwave ovens are 2.45 GHz (12 cm) for home ovens and 915 MHz (38 cm) for industrial overs. Much higher frequencies are not used due to the cost of the magnetron, while much lower frequencies would not work because the wavelengths would be too big to allow a half wavelength to fit in the oven.
Finally, you say:
Why do we use microwaves in microwave oven when infrared and visible light are much hotter and how do microwaves cook food when they are cooler than visible light and others.
But this is a slight misunderstanding. The wavelength of light emitted is indeed related to the temperature of the source, but light itself doesn't really have a temperature in the sense that matter does. Light transfers energy, and if this energy is absorbed it will heat the food. However the amount of heating is just related to the intensity of the EM radiation and the abosrption cross section. The wavelength makes a difference only insofar as it affects the absorption cross section.
Shorter wavelengths tend to absorb and heat the outer layer of object. Microwave uses long wavelength to penetrate to inside and also it uses the property of dipole moment of water molecule to heat things, it does not directly heat by letting object absorb energy.
If we just used short wavelength, then the food could only get burnt outside and remain raw inside.
Both visible light and IR is used for cooking. Visible light is used in solar ovens (basically mirrors concentrating sunlight on a food item). IR light is used in a normal oven (the walls of the oven are heated, which causes them to radiate significant amount of heat as IR); grills use the same approach, just with higher temperatures. If you've ever baked/grilled something wrapped in tinfoil, the point of that is to exclude the IR radiation (and rely on air heating instead).
So the first part of the answer to your question is simple enough - if microwave ovens used visible or IR light, we would not call them microwave ovens, just ovens.
But microwave ovens weren't sold as "this is a lot more awesome, because it uses microwaves!". The selling point of microwave ovens is that they heat the food with a lower power input. This requires two things; first is conversion efficiency: how much electricity it takes to produce the radiation. However, a simple oven (gas or electric) is hard to beat in that respect - it's very close to 100% efficient, since the waste heat is actually what causes the heating. Microwave ovens are built to use radiation sources that are as efficient as possible (while also not interfering with other electrical devices), but those are still less efficient than a piece of resistive wire or an ordinary light bulb.
So if microwave ovens aren't more efficient in power conversion, how come they're so much faster at heating food? Their selling point (besides things like small size and weight) was that they heat the food, not the container, and the oven, and the air, and.... This doesn't sound all that important, but it's actually a very big deal. Ovens need a lot of energy to heat up; not a big deal if you're cooking something for eight hours, or if you make a lot of meals (e.g. pizza ovens in a restaurant), but if you just want to heat a quick meal, most of the energy is wasted. Stoves need to heat the pan, and of course, even when you're just reheating a meal, you often need to heat quite a bit of extra water (and vaporize most of it, so the food isn't soggy).
Are microwaves uniquely suited for this task? Kind of. They're not readily absorbed by kitchenware, and they're not even scattered all that much (compared to e.g. visible light reflecting off a white plate). At the same time, they're extremely well absorbed by both water and fats, and most of our foods are full of water. So you definitely want very long wave radiation. How long? That depends on other constraints. Too long waves mean the oven becomes too large, and one of the big benefits of microwave ovens is that they're very small appliances. Many frequency bands of long-wave radiation are already used for communication - radios, Wi-fi, cellphones... so you don't want to interfere with that. You also need to avoid inducing current in wires outside of the microwave. Short waves are a lot more tricky to produce using the equipment - a radio is more power efficient than a microwave, and visible light is even worse. An actual engineer who deals with microwave ovens could probably tell you a hundred constraints off the top of his head :)
Microwaves are very efficiently absorbed by water molecules in the food. Water molecules are small electrical dipoles that wiggle at microwave (GHz) frequencies when in the liquid state. Microwaves resonate with this wiggling motion. Watermolecules are everywhere in our food and drinks so via these the rest of the food constituents are heated by conduction. In ice the molecules wiggle at kHz frequencies which is why defrosting in a microwave oven really does not work.