Prior to their use in the microwave oven, microwaves were used as part of radar communication, and it is in this capacity that an American named Percy Spencer inadvertently discovered that microwaves could be used to cook food. During WWII, Spencer was working on radio transmitters for Raytheon as part of the 1945 war effort.
One day, he noticed that a candy bar in his pocket was melting near the equipment. With this, he discovered that microwaves could heat and cook food. Spencer went on to create the world's first microwave oven, which was patented by Raytheon. Spencer himself received no royalties for his invention beyond a $2 reward from his corporate bosses.