When someone says, "If you know what's good for you," it is a warning or a threat to someone, implying that they should act in a certain way or make a specific choice to avoid negative consequences or harm. It suggests that the speaker knows what is best or beneficial for the other person, and if that person wants to avoid trouble, they should follow the advice or comply with the implied demands.
It can be used in various contexts, from playful banter to more serious and potentially threatening situations. It is often an attempt to assert authority or control over someone, and the exact meaning and tone depend on the context and relationship between the speaker and the listener. In some cases, it may be intended as a humorous remark, while in others, it may be a way to pressure or manipulate someone into doing something.