  We investigate the dynamics of two bosons trapped in an infinite
one-dimensional optical lattice potential within the framework of the
Bose-Hubbard model and derive an exact expression for the wavefunction at
finite time. As initial condition we chose localized atoms that are separated
by a distance of $d$ lattice sites and carry a center of mass quasi-momentum.
An initially localized pair ($d=0$) is found to be more stable as quantified by
the pair probability (probability to find two atoms at the same lattice site)
when the interaction and/or the center of mass quasi-momentum is increased. For
initially separated atoms ($d \neq 0$) there exists an optimal interaction
strength for pair formation. Simple expressions for the wavefunction, the pair
probability and the optimal interaction strength for pair formation are
computed in the limit of infinite time. Whereas the time-dependent wavefunction
differs for values of the interaction strength that differ only by the sign,
important observables like the density and the pair probability do not. With a
symmetry analysis this behavior is shown to extend to the $N$-particle level
and to fermionic systems. Our results provide a complementary understanding of
the recently observed [Winkler \textit{et al.}, Nature (London) \textbf{441},
853 (2006)] dynamical stability of atom pairs in a repulsively interacting
lattice gas.
