Optimality and Stability in Federated Learning: A Game-theoretic Approach