In a relationship, it's not THAT important and shouldn't be, even though it should be part of it imo.
Generally speaking, sex can be essential to building confidence and a strong self-image, depending on the person ofc. I say that as a guy who hasn't got any in..... way too long.
I notice that I feel different about myself and my life than I did when I used to have sex. It's sad but true, satisfying sex can give you a huge boost in confidence and also energy.