Most of the risks are anesthesia related, the risk of going to sleep and potentially not waking up. Thankfully that’s very low in the US. Risks that may cause complications include cardiac conditions, heart attack, and pulmonary problems and are more likely a direct result of the anesthesia itself than of the joint replacement.
The surgery itself has a risk of infection, neurovascular injury, stiffness, and, particularly with the hips, dislocation of the implant. Many of these risks are quite low. Other risks include loosening of the implant itself in the hip. If this occurs, deep bonding of the surface that grows into the implant would be required. In the knees, loosening of the cement that holds the knee replacement in place can occur with time. Many of the risks associated with older implants were wear-related conditions such as wearing out the prosthesis. This is less common these days as the implants are made with more integrity and longer lasting implants.