This was explained in the prequel novel Catalyst.
Basically, Erso was always a pacifist and never wanted his work to be used to create weapons. Krennic tricked him into working for the Empire on his research by making Erso believe that the work was being used in energy generation and that in other labs other teams were working to contain the energy that Erso was coaxing from the Kyber crystals.
When Erso discovered that in actuality, Krennic was developing methods to release the energy as a focused beam weapon, Erso, his wife and daughter fled Coruscant and hid on a backwater world.