There's a space in your joints filled with synovial fluid, a liquid that reduces the friction in your joints when you move. It contains gases (oxygen, nitrogen, and carbon dioxide).
When you pop a joint, you stretch out that space between the bones. That expanding space creates negative pressure, like a vacuum, that sucks in the synovial fluid. It forms bubbles, which then collapse, and that's what you hear.
Most medical sources agree that unless you experience pain when you pop your joints, you're probably fine to keep doing it. Researchers (including one man who cracked his knuckles on just one hand for 60 years) haven't established a connection between cracking your knuckles and arthritis.
One 1990 study of 300 people did find that cracking knuckles over a long period of time led to hand swelling and decreased grip strength, but there hasn't been any follow-up research on that.