An API, or Application Programming Interface, is a communication protocol between two sets of code. It's like a language; both parties agree that words have a particular meaning, so that they can talk to each other.
Why? Because Software is Hard.
Hardware makers do their best not to agree on how hardware should be made. Power requirements & connections have to be standardized, but how do you think they could actually make such a great XYZ5000 if they actually told you how they did it?
Originally - especially when a new computer comes out - people wrote code to talk directly to the hardware. MSDOS games routinely wrote directly into the video memory for fastest results. When you start having multiple programs running simultaneously, they all can't do that, any more than everyone at a meeting can all talk simultaneously, so eventually APIs and driver programs would do the work, and programs would call them in order to play nice with everyone else.
A driver implements a particular API that the operating system requires for interfacing with a certain kind of hardware. So hardware makers write 'software drivers' that allow your lowly computer to understand & communicate with the awesomeness that is their XYZ5000, at least on a basic level.
However, Microsoft, Apple, or the various makers of the various *nix's are not stupid; they know there's malicious (or just poorly written) code out there. They are not just going to let any old program willy talk to drivers. Especially drivers relating to drawing stuff on the screen. The OS needs to know about this sort of thing, and it needs to manage access to that hardware.
So the OS exposes an API that allows other programs to talk to the hardware.
OpenGL, Vulkan, and Direct3D (known by most people as DirectX) are the three available APIs for dealing with 3D graphics. An interesting aspect of these APIs is that, because they directly access hardware, their features are very reliant on the underlying code. Previous graphics cards may work, as there's usually a built-in render path using older versions, but you usually won't see the new features. There are also programs which implement the API in software, although the featureset and performance is always well under what you can find in hardware.
Currently, Vulkan, Metal and Direct3D 12 are the ones touted as "next generation graphics API's", due to them being a lower-level API than their predecessors, meaning it can access hardware resources more efficiently, and make lower-end graphics cards and systems run otherwise hard-to-run software and games...well, that's the theory anyway. However, while Direct3D 12 was initially implemented first into games, Vulkan currently has more games that utilise its API, due to it's benefit of being cross-platform with Windows 7, 8, 8.1 and 10, as well as macOS (via the MoltenVK API), Linux, Android etc, while Direct3D 12 can only officially be used universally on one platform: Windows 10, though DXVK can translate Direct3D 12 calls to Vulkan on Linux, and some games have been updated to support a modified Direct3D 12 runtime to run on Windows 7. Similarly, Metal is exclusive to Apple devices, such as the iPhone and Macs. Fun fact: The first piece of software to feature both Vulkan and Direct3D 12 support is Dolphin, the Wii / Gamecube Emulator, though it was removed initially, as the developers canned the Direct3D 12 backend in favour of maintaining the then-maturing Vulkan backend, partially due to abandonment, as more devs were willing to support Vulkan instead, as the multi-platform nature of Vulkan made it more useful to Dolphin as it can run on anything Dolphin runs on, and it was almost 2 years until Direct3D 12 support came back. to the emulator. This was followed by half-benchmark, half game Ashes of the Singularity.
Frequently, how efficiently these pieces of Hardware work with APIs depend not only on the hardware, but on how nicely they play with APIs (part of software drivers). The amount of work put into this, in part, is determined by how much money they expect to make from them. In the future. So old hardware slowly migrates to the great big garbage dump in the sky, because there is no money to be made.
There have also been cases of newer graphics cards omitting or otherwise breaking little-used features that some games during the Direct3D 7 and prior era used, either at the driver or hardware level, so don't expect perfect backwards compatibility. Sometimes you might just have to build an old computer to run a suitably old game well, or even at all.