Reputation can promote cooperation in public goods game and player's cooperative behavior is not pure economical rationality, but habituation would influence their behaviors as well. One's habituation can be formed by repeated behaviors in daily life and be affected by habitual preference. We aim to investigate the sustainable cooperation based on reputation and habit formation. To better investigate the impacts of reputation and habitual preference on the evolution and sustainability of cooperation. We introduce three types of agents into our spatial public goods game. Through numerical simulations, we find that the larger habitual preference make cooperation easier to emerge and maintain. Additionally, we find that a moderate number of agents who want to obtain more reputation (ICs) are best for the sustainability of cooperation. Finally, we observe that the variation of donations of ICs can influence greatly on the equilibrium of public goods game. When ICs reduce their donations, a proper contribution will be better to maintain the cooperative behaviors.