By law and regulation the FDA has certain procedures to follow before approving a drug, and if anyone has questions about it, again by law the FDA has certain procedures for answering the challenge.
Congress set up these laws, and can change them if they're in need of change.
So, in this case the FDA itself failed to follow those procedures for over twenty years, leading to this mess.
No, courts are not supposed to be directing medical studies because that's outside the area of expertise of a judge.
Here's the Texas opinion that lays this all out: