Tantalus, who was a king beloved of the gods, ruled over the kingdom of Tmolus. He hated his sons. He fed the gods human meat, specifically Pelops, his son, and tried to trick them. Later he was sent to Fields of Punishment for trying to trick them. Why?
According to this Wikipedia article about Atreus it was to test the omniscience of the gods. He wanted to know if the gods would know it was human flesh. Not only was it human flesh, it was the flesh of his son, Pelops.
This article on "Greek Myths & Greek Mythology" suggests that it was for one of two reasons, either to test their genius, a similar story to that in the Wikipedia article, or simply because he ran out of food to serve them. Perhaps worth noting that this was not Tantalus's first offense.