Does the dipole moment increase or decrease by increasing the bond length? It is established the dipole moment is a result of multiplication of the magnitude of charges (Q) and the distance between them (r). What I understand is that when an electron and a proton get closer (bond length decreases), polarity decreases hence the dipole decreases. When they move further away from each other(bond length increases), the polarity increases and hence the dipole moment increases. However, in case of halides (H-X), let's take for example HF and HI, HF has a bigger dipole moment than HI, it is stated that the bond length of HF is smaller than HI. Why do I find this contradictory?
Can you help me with What I am missing here?
Strictly speaking, you can neither decrease nor increase the bond length a slightest bit.$\dagger$ All molecules of a given compound are equal. It is not like you may grab one with tiny pincers of some sort, stretch it a little and see what happens.

You may, however, consider a molecule of a different compound; indeed, that's what you do in your question. But that's not just a different bond length; it is different atoms with different properties, and hence different everything.

Most importantly for the question at hand, iodine has much lower electronegativity than fluorine, so the effective charges on $\rm H$ and $\rm I$ in $\ce{HI}$ will be much lower than those on $\rm H$ and $\rm F$ in $\ce{HF}$. It just turns out that the increase in bond length can't compensate for this effect, hence the lower dipole moment.


$\dagger$ For those who might want to point out possible vibrational excitation or some other subtle (or not-so-subtle) effect: don't. Let's keep it simple.