Relay Controlled Gain for Microcontroller
Check out analog multiplexers like 4051. These devices are commonly used for this kind of application. In practice they form an analog (and in fact bilateral) connection between one of the 'inputs' (Y0 - Y7) and the output (Z), selected by a binary selector (A0 - A2). It would replace all your relays (up to eight) and you set attenuation per input by a resistive divider. With a supply voltage of 10V the ON resistance is in the order of couple 100\$\Omega\$.

Similar story goes for 4052 which has 2 independent 4 channel analog (de)multiplexers.

Basically the same circuit as yours:






simulate this circuit &ndash; Schematic created using CircuitLab

Another possibility is to use an DAC and feed your input signal into its reference voltage input and select the attenuation with the digital input. Not all DAC's are fast enough for this application, but it can give you many bits of resolution.