God cannot do rationally impossible things.
Generally there are two types of impossibilities: 1, The common impossibilities. 2, Rational impossibilities.
Common impossibilities are those things which are impossible under certain conditions although the mind does not consider them to be impossible in every condition. It is possible for the mind to image their occurrence if the prevailing conditions were different. Examples of common impossibilities are: bringing the dead back to life, transforming a stick into a snake or making the force of gravity on the Moon to be stronger than that of the Earth.
All those things are generally considered impossible for humans to do, however the mind does not deem them absolutely impossible. A being with sufficient knowledge and power may be able to do those things. Perhaps in the future, with the progress of science, human beings may have the ability to do many things that are considered to be ordinarily impossible today.
It is believed that God is capable of performing all common impossibilities since God is omnipotent and omniscient. He is able to bring things into existence, manipulate the composition of the universe and is also able to manipulate the laws of physics.
Rationally impossibilities are those ‘things’ which the mind can never accept as being possible under any circumstance. Some examples: a four sided triangle, a square circle, a married bachelor, a parent that never had any children & 2 + 2 = 5.
None of the above can ever exist. The mind can never imagine a four sided triangle, and a triangle by definition, always has three sides. All of those things are absolutely impossible since they bear contradictions.
Many great philosophers and theologians throughout history have held the belief that God himself cannot do the rationally impossible. That is, God cannot do things like create four sided triangles. This is a belief that has also been taught by the official leaders of Islam:
Imam Ali [a] was asked: “Does your Lord have the power to place the Earth in an egg, without making the Earth smaller or the egg any bigger?”
He [a] replied: “Verily, Allah, the blessed and exalted, cannot be attributed with deficit/inability. However, what you have asked is impossible.” 
When Imam Al-Sadiq [a] was asked a similar question and he said: “Although God’s power is infinite, nevertheless, what you are asking is a nothing.” 
Thus the Imams [a] state that God can do everything except that which is impossible in itself. Imam Al-Sadiq [a] points out that rational impossibilities are considered to be nothing (la shai) because they can never exist. The inability do the rationally impossible is not really an inability since the rationally impossible is not a thing. God can do everything except that which is ‘nothing’.
Some religious people falsely believe that God can do rational impossibilities; they believe that human logic should not be able determine what is impossible for God. However this argument is self-defeating because it allows for the dismissal of ‘human’ reasoning and the argument itself relies upon human reasoning.
If God were able to do the rationally impossible then it would lead to the breakdown of human reasoning. It would become acceptable to say things like: “There is a square circle in that room” and “2 + 2 = 5” since it could be argued that God willed for things to be that way. It would be acceptable to contradict the laws of thought . Humans would be allowed to make irrational arguments with the justification that God is able to do anything.
The notion that God can do the rationally impossible is something that is sometimes promoted by people whose religious beliefs entail contradictions. They desire to justify those contradictory beliefs by invoking the infinite power of God.
 Shaykh Saduq, Kitab Al-Tawhid, chapter 9 narration 9.
 Ayatullah Jawadi Amuli, A commentry on Theistic Arguments, pages 219-220.