It isn't always simply:
“This is a good song.”
The song has to fit the scene.
The mood.
The timing.
The characters.
The story.
Sometimes filmmakers already know exactly what they want, other times they test several possibilities then there are rights and licensing.
Who owns the recording?
Who owns the composition?
Can it be used?
How much will it cost?
The audience hears a few minutes of music, behind that moment can be a surprisingly complicated decision.