My dog practices selective listening. When he doesn't like what I am saying, he acts as though he doesn't understand me. If he is in my room at bedtime and I tell him to leave, he looks at me as if to say, "What?" It's as though his hearing is gone. On the other hand, he can be asleep behind closed doors, and if I go downstairs, open the cupboard, and pull out his leash, he suddenly has supersonic hearing. He is right there at my side. When he likes what I want him to do, my dog hears and obeys me. But when he doesn't like what I want him to do, my dog doesn't hear and doesn't obey.
We can be the same with God. When God tells us to do something we like, we say, "Yes, Lord!" But when He tells us to stop doing something, we say, "God, I think you're cutting out on me. There's too much static. I'm not hearing you clearly."
Jesus said, "You are My friends if you do whatever I command you" (John 15:14). He didn't say, "You are My friends if you do the things that you personally agree with." God has told us in His Word how we are to live. It is not for us to pick and choose sections of the Bible that we like and toss the rest aside.
If God tells you to do something, He says it for good reason, and you need to obey Him. If God says not to do something, He also says it for good reason. Even if you don't understand it, obey Him.