First-principle calculations of the lattice dynamics and electronic band structure were carried out for MgB2 superconductor. The inelastic neutron scattering measurements of the phonon density of states were also determined. The giant anharmonicity and nonlinear electron-phonon coupling in MgB2 was also studied. The results showed that the harmonic phonon energy in-plane boron phonons near the zone center are very anharmonic and strongly coupled to the planar bands near the Fermi level.