아내에게 주려고 선물을 샀어요.
I bought a present to give to my wife.
잠을 자지 않으려고 커피를 5잔이나 마셨어요.
I drank five cups of coffee so that I wouldn’t go to sleep.
-(으)려고 expresses the intention or plan of the speaker. Specifically, it indicates the speaker will do what is stated in the second clause to accomplish what is stated in the first clause. It corresponds to ‘(in order) to’ or ‘so that’ in English. When the verb stem ends in a vowel or ㄹ, then -려고 is used, and when it ends in a consonant, -으려고 is used.
A: 정아 씨, 요즘 학원에 다녀요?
Jeonga, do you attend an academy these days?
B: 네, 컴퓨터를 배우려고 학원에 다니고 있어요.
Yes, I go to an academy to learn how to use computers.
A: 아까 만났는데 왜 또 전화했어요?
We just met a little while ago, so why are you calling again?
B: 당신 목소리를 들으려고 전화했어요.
I called so that I could hear your voice.
A: 자려고 누웠는데 잠이 안 와요.
Even though I’ve lain down in bed, I can’t go to sleep.
B: 그러면 따뜻한 우유를 한 잔 마셔 보세요.
In that case, try drinking a glass of warm milk.