In many cases it is not necessary for a diagnosis, but physicians order a MRI (for example) because their training pushes them to order one each of everything. Then the patient (or the insurance company) pays for it. The physician gets no compensation for ordering the test, in most cases.