The main purpose of an ID card is to identify, with some reasonable level of confidence, the person presenting the card. ID cards are generally used to gain access to some valuable service, such as boarding an airplane, or accessing the gym. There is a strong interest in making sure that the person accessing the facility is indeed the individual meant to do so, and not an imposter. Wherever identity verification is critical, checking the face of the person presenting the card against a photo on that card has been a standard form of verification for many years. It is the same reason that any passport, not matter which country issued it, has a photo in it, which is carefully checked by customs/border agents whenever you enter a country.
In fact, photos were the earliest form of a “biometric” – something that is directly and intrinsically associated with a person’s identity. Modern forms of biometrics include fingerprints, retina scans, and facial recognition. But the earliest version was the humble photograph, which when matched to a face generally allowed a high degree of confidence of making a reliable identification. Photos on ID cards were among the earliest attempts to make those ID cards fraud-resistant.
Cards have become a more portable, useful version of the well-known International Passport, issued by the State department of each Country, to allow travel across borders. All passports contain a photo, as described here for the United States: https://travel.state.gov/content/travel/en/passports/how-apply/identification.html