What does the sphinx represents in Greek and Egyptian mythologies?
The only thing we hear about him is that he asks a question to which any human could find the answer once you know it, and eats the ones who fail. What does that teach to people? I thought mythology then was to provide morale to people?
Not all mythologies provide morals. Sometimes, they explain parts of the world that were not well understood, or just exist to be good stories in some cases. The Greek Sphinx is related to the story of Oedipus Rex (of later Freudian fame), as he is the first to answer the Sphinx's riddle. This could be tied into Oedipus's characterization, (but this is just speculation), contrasting his wisdom when answering the Sphinx with his downright obliviousness when it came to other parts of his life, like realizing that he was sleeping with his mom (read Oedipus Rex or look it up, it's great). Her death could also represent a transfer from older deities to the fresher Olympian pantheon. The Egyptian Sphinx was more a symbol of protection, a benevolent guardian without the riddle thing. You could draw connections with both creatures being protectors, one a malevolent gatekeeper and the other a guardian.