The phrases follow the basic meanings of 이(this), 저(that), and 그(it, such).
이 indicates something near the speaker (it could be away from the listener or close to both of them).
저 indicates that it is away from both people.
그 can mean an object away from the speaker and close to the listener, or something previously referred to.
* 그거 어디서 났어? = Where did you get it/that?
* 이건 친구한테서 선물 받은 거야 = This is a present I received from my friend.
* 저 건물 참 잘 지었다 = That building is really well built.
그래, 저래, 이래 are short for 그렇게/저렇게/이렇게 해, where 해 can refer to an action or something verbal. These words can also indicate a state, as when someone looks to be in an unusual condition (e.g. if your friend looks sad, you might ask 왜 그래?, to mean "Why are you like that?").
Their exact meaning can thus vary with the situation, but here are the common use cases.
* 왜 그래? = Why are you doing that [like that]? (the speaker asks about the listener)
* 왜 저래? = Why are they doing that? (The speaker asks about a third party, away from the speaker and listener)
* 왜 이래? = Why are you doing this (to me)? (The speaker asks(or complains to) the listener about what they're doing to or near him/her - it may or may not be caused by the listener)