Its not that he created the components of the equation from thin air. You are allowed to have anything you please on either side of the equation as long as you find it that the units cancel each other out. He had time on one side, and $\sqrt{h/g}$ which, if you speak in strictly dimensions, is $\sqrt{meters/meters/seconds ^{2}}$ you clean up that equation $\sqrt{meters \times seconds ^{2}/meters}$ which is finally equal to seconds. The two sides of the same units.