There are many ways to do this, but they all depend on the same basic fact that the sines and cosines of the angles $36°$ and $72°$ involve $\sqrt 5$. For example $\cos 36° = (1 + \sqrt 5)/4$. Since $\sqrt 5 = \sqrt{1^2 + 2^2}$, These angles can be constructed by starting from a right-angled triangle with sides $1$, $2$, and hypotenuse $\sqrt 5$.
In the OP's construction, is should be obvious how the $\sqrt 5$ appears in the length of AE and AB.
Euclid gave a (rather long winded) construction in Elements, book IV, proposition 11 and proved it was correct using only geometry.
It is usually easier to prove that "quicker" constructions like the OP's are correct using trig, rather than pure geometry.
The more general question of "which regular polygons can be constructed using only ruler and compasses" (i.e. no measuring instruments allowed) was answered by Gauss. Only 31 such polygons with an odd number of sides are known, the smallest ones having 3, 5, 15, 17, and 51 sides. The largest known one has 4,294,967,295 sides. It is an unsolved mathematical problem whether any more exist, and if so whether there are a finite or infinite number of them.
See: