The temporomandibular joint is the most complicated joint in the body. No other joint moves the way it does. It not only rotates, but it also translates. That is, as you open really wide, the joint actually dislocates. There is an articulating disc between the condyle on the jaw and the fossa on the base of the skull that keeps bone from grinding on bone. It has muscles attached to it to move it in concert with the condyle as it translates down the plane of the fossa. It is a well choreographed dance.
LOTS of things mess up the dance. An uneven bite. Muscles not synchronized. Loss of vertical dimension due to worn teeth or dentures. Too much vertical dimension due to high crowns, fillings or dentures. Deterioration of the articulating disc. Muscle spasms. Injury. Inflammation. There are lots more problems, but you get the drift.
The solutions are as varied as the causes. I'm not going to give any here because of legal reasons. My suggestion is to talk with a general dentist who has lots of experience treating this AND and an oral surgeon who has experience too.