This paper studies the connection between a class of mean-field games and a social welfare optimization problem. We consider a mean-field game in function spaces with a large population of agents, and each agent seeks to minimize an individual cost function. The cost functions of different agents are coupled through a mean-field term that depends on the mean of the population states. We show that although the mean-field game is not a potential game, under some mild condition the -Nash equilibrium of the mean-field game coincides with the optimal solution to a social welfare optimization problem, and this is true even when the individual cost functions are non-convex. The connection enables us to evaluate and promote the efficiency of the mean-field equilibrium. In addition, it also leads to several important implications on the existence, uniqueness, and computation of the mean-field equilibrium. Numerical results are presented to validate the solution, and examples are provided to show the applicability of the proposed approach.