The real part of optical conductivity, Reσ(ω), of the Mott insulators has a large amount of information on how spin and charge degrees of freedom interact with each other. By using the timedependent density-matrix renormalization group, we study Reσ(ω) of the two-dimensional Hubbard model on a square lattice at half filling. We find an excitonic peak at the Mott-gap edge of Reσ(ω) not only for the two-dimensional square lattice but also for two-and four-leg ladders. For the square lattice, however, we do not clearly find a gap between an excitonic peak and continuum band, which indicates that a bound state is not well-defined. The emergence of an excitonic peak in Reσ(ω) implies the formation of a spin polaron. Examining the dependence of Reσ(ω) on the on-site Coulomb interaction and next-nearest neighbor hoppings, we confirm that an excitonic peak is generated from a magnetic effect. Electron scattering due to an electron-phonon interaction is expected to easily suppress an excitonic peak since spectral width of an excitonic peak is very narrow. Introducing a large broadening in Reσ(ω) by modeling the electron-phonon coupling present in La2CuO4 and Nd2CuO4, we obtain Reσ(ω) comparable with experiments.