Two reasons to bet, and no third
When you bet, you are after one of two things.
Value: you think you have the best hand and you want a worse hand to pay you. The bet works when your opponent calls with something worse than yours.
Bluff: you think you have the worse hand and you want your opponent to fold a better one. The bet works when your opponent folds something better than yours.
To tell which one you are doing, think about your opponent's range, every hand they can hold at this point in the hand. Then ask two questions. Which worse hands will call? Which better hands will fold? If the answer to both is "none", the bet does nothing: check.