In Oedipus Rex what has Oedipus done to deserve such awful suffering?
This is a very difficult question to answer, because we are dealing with the divine in the Greek world. In other words, there was a prophecy that Oedipus would marry his mother and kill his father. In view of this prophecy can we say that Oedipus is guilty for his crime? From a modern point of view, we might be tempted to say no. However, we must not be anachronistic, because there is another side to things.
Oedipus all throughout the tragedy is filled with self assurance and pride. He thought he could solve any problem. The Greeks called this "hubris," and Oedipus had plenty of it. He crossed the boundaries of what was proper and "caught" the attention of the gods. In light of this, he needed to be humbled. This is an important concept in the Greek world, because there was a strong line of demarcation of divinity and humanity. Oedipus crossed it. So, in his sense he is guilty.
In the end, this will continue to be a question.
It's his Hubris at the beginning of the play- look at his opening speeches where he says (and I'm paraphrasing wildly here) "Why are you worshipping the gods? I will solve your problems!". Also, his disbelief in the oracle and the priest Tiresius are hubris- Apollo is the god of prophesy, and by disrespecting these two Oediupus is disrespecting a god.