Is A Cervical Exam Necessary?

My ob wants to do a cervical exam , I was just wondering is it necessary? I’ve been reading online how there’s risk to it : risk of infection & rupturing the membranes. Also how it doesn’t really tell you if your actually going to go to labor & that it can be painful. Can I refuse a cervical exam ? Or is it a must ? Btw I’m a first time mom so I’m all new to this any advice is appreciated.