Consider a right triangle like here, i.e., the hypothenuse is denoted by h, opposite side is a and adjacent side is b.

Then:

sinθ=a/h

cosθ=b/h

and you know from Pythagorean theorem that .

So if you calculate , you get

You can even simplify this by rescaling the triangle so that h=1. (In case you're familiar with unit circle definitions of trigonometric functions, you should know, what I mean.)

BTW you have a whole article about this identity at wikipedia.