It comes from the Taylor expansion of the potential energy function. We don't know what U(x) is, so we take the Taylor expansion of it around 0. You can add a constant to any potential energy function and it won't change the physics, so we can let the first term equal zero. If we define the equilibium position to be zero, then U'(0) must be 0 since it is in equilibrium. If it weren't zero, then it wouldn't be the equilibrium position. That leaves us with the third term, 1/2 kx^2, where k = U''(0). Terms beyond the third are ignored, since we assume that three terms of the Taylor expansion will be a good approximation for small displacements (which is was 1/2 kx^2 is valid for). That's where the 1/2 comes from.