Some in the military wanted a democracy and a secular country. Turkish president Erdogan, has cracked down on free press, etc. Those in the coup are worried about his leanings toward a more Islamic society.
Reports are out now that it failed because the military could not keep President Recep Erdogan out of the picture. He regained control as soon as he flew back to Turkey and had the support of his senior military advisers. And it failed because there was little political support or public backing.
Last night Bill O'Reilly said, "this is what happens when the United States steps back and tries to become one nation of many, and doesn't lead."