As with troubleshooting most hardware issues - experiment, restart, reset. It can either be an issue with the driver in which case a simple restart (maybe a “hard” smc reset as well) fixes the problem, or a hardware problem with the bluetooth antenna which would require a swap of the chip itself, but is usually on the macbook/iphone side, not the airpods and would affect all of your bluetooth connectivity. I’ve had both types of issues and it sure sucks. Had to replace an antenna cable in an iphone 6 to be able to connect to my airpods again.