What is the main function of the joint capsule?

To Stabilize Joints. The joint capsule provides joint stability. If injured it can lead to stiffness and may then be surgically removed, without compromising stability as long as the joint's ligaments are kept intact. While this seems counterintuitive, it's because joints can undergo changes that turn the capsule from a necessary structure to a problem that is best removed (it regrows back more normal).