Even if an alternative fingering is possible, I would argue that being able to play a barred chord like this is a skill that is worth learning. I would approach this chord like so:
Bar at 5th fret with middle finger on the 6th fret 3rd string and the ring finger on 7th fret 1st string. Pretty straight-forward.
Now, how you can prevent accidentally muting the 2nd string? Try increasing the angle of attack on your fingers, i.e. try to have the finger tips more perpendicular to the fret board. That prevents your middle finger and your ring finger from muting the second string. However, I think your problem is most likely that there is not enough pressure on your index finger barring at the 5th fret. Try barring closer to the fret, as you need less force there. Many people use the less fleshy side of their index finger to bar, so try tilting your index a little bit towards the headstock. Lastly, try to find a position for the index finger where you can apply optimal pressure to the 2nd and 4th string. Some parts of your finger are just better at pressing down strings and this can be individual.
Practice by using the chord in a higher position where your fingers do not have to stretch as much. Strum the chord slowly until you can hear all strings clearly.
Next, play the chord at the intended position and practice there. Notice the difference in the finger positions from the wider frets. If you can play it here with some effort, you can practice coming from a different chord to this one in order to generate the muscle memory to play this chord reliably. In the end, muscle memory is all that it is.