If the decibel represents a gain ratio, why do we use it in sound measurements?
Let me correct you; the decibel represents a ratio, and when used to talk about amplifiers, it represents a gain ratio. But in other cases (such as sound) it represents a ratio to the threshold of sound (20 μPa): -
Image from here.
Why is it necessary to calculate such a thing and give the ratio of it? Why didn't they measure the sound level of the environment to be measured directly and express it with a unit suitable for it?
Well, if we said that the human ear can detect sound from 20 μPa to 20 Pa, that's a scale of 1,000,000:1 and, it's more meaningful to rescale it to something from zero to 120 dB SPL.