why we can use dimensional analysis to discover formulas? if I want to discover the time duration ($t$) of a object falling from an heigh ($h$) to the ground in a gravitational field ($g$), I can guess that $t$ is proportional to $h, g$ and the mass ($m$). then, with some $K$ as an adimensional, we have:
$ t\space = k \space m^\alpha h^\beta g^\gamma$
then we use dimensional analysis to discover that $\alpha=0, \beta=1/2,\gamma=-1/2$
then
$t=K\sqrt{\frac hg}$
ok.... but why we can use this in the first place?
I know that there is some Principal of Homogeneity of Dimensions, but what is the foundation of this principle?
 A: The basic idea goes back to Stoney.  Quoting from Barrow and Tipler in “The Cosmological Anthropic Principle”: 

In 1874 the Irish physicist G. Johnstone Stoney first discussed the possibility that there exist particular systems of units picked out by Nature herself, what we might term 'Natural Units'.

Basically, Stoney reasoned that, given a set of constants, there would be some natural scales (or typical values) for the phenomena described using these constants.  This is the basic premise and it has been shown to hold almost universally.
If you have an object falling under gravity at some constant acceleration $g$ over a distance $h$, you immediately inject physics in the problem by choosing units and thus numerical values for $g$ and $h$.  You would pick $g=9.8m/s^2$ and $h=1$m because on Earth things typically fall over several meters and over some seconds.   As a result, the “natural” time you can construct for this is 
$\sqrt{h/g}=\sqrt{1/9.8}\approx 0.3$, telling you that falls over meters in height will take on the order of seconds.  The exact value is not of primary importance; what matters is that this scale is  not minutes or milliseconds.  
Note that it’s impossible to find an “exact” formula using this method because it’s not possible to evaluate dimensionless proportionality factors, but it does allow you to get an idea of the orders of magnitude involved since experience has shown these dimensionless factors are typically of size $1$, i.e. neither small nor large.
In the same way, if you ask what are typical atomic energies, you might construct an energy scale using $m$ (mass of electron), $e$ (charge of electron), $\epsilon_0$ from Coulomb’s law, and $\hbar$ to make account for the quantumness of the situation.  You’d then get
$$
E= \frac{me^4}{\hbar^2 \epsilon_0}\approx 13.6eV. \tag{1}
$$
which is just right.  Note that, if you choose to use $h$ rather than $\hbar$ (both have the same units and just differ by a factor of $2\pi$), you’d be off by a factor of $6$ but still in the eV range.  Not MeVs, not $10^{-3}$eV, but just about right.  You can tinker and use the more common $4\pi\epsilon_0$ rather than just $\epsilon_0$ to get a numerically different answer, but still in the same eV range.  
This shows that you cannot obtain “new formulas” from dimensional analysis, as you can easily be out by some dimensionless factors; rather, you can discover that quadrupling $h$ will double the time, or that the time it takes to fall on the Moon is relate to that on Earth by $t_{Moon}= t_{Earth}\sqrt{g_{Earth}/g_{Moon}}$, i.e. object take longer to fall on the Moon.  You can work out typical energies of muonic atoms by replacing $m$ by $m_\mu$ in (1) since the rest of the physics has not changed.
Thus you’re not “discovering” new formulas, but rather relating known quantities to obtain typical values for the quantities in your system.
