For the word "careful" (KJV) in verse 40, the margin reads "distracted," which is also how the NKJV translates it. In the Greek, it is the same word translated as "anxious" in Matthew 6. Anxiety distracts.
Consider doing a job under distracting conditions, when several things are competing for attention at the same time. Jesus says that no man can serve two masters (Matthew 6:24). What will happen when a person's mind has two or more issues simultaneously vying for attention? Eventually, the person will dismiss one of them in order to pay attention to the one he chooses to give his attention to. That is the principle here. It is that simple.
If two matters work on the mind, they cannot be given equal time. The mind will shift gears so that one gets the priority over the other. We need to see this principle in relation to the Kingdom of God. By making the Kingdom of God our treasure and having a clear understanding that this principle is at work, Jesus wants us, by faith, to choose to set our will to make God's Kingdom our first priority. It is something that we must make the choice to do.
So Jesus says to Martha , "You are distracted [troubled, worried, anxious] about many things." There is nothing wrong with serving, but Jesus is showing that service has to give way to worship. Even if we understand that worship is a form of submissive service, it is ratcheted up several notches higher because it is service given directly to God. This is a gentle rebuke by Jesus urging Martha to leave her housework for the time and concentrate on the more urgent responsibility, because Christ would be living among them only a little while longer. Under this situation, Mary had made the right choice. She had a clearer understanding of the circumstance and made the better choice of the use of her time.
His words do not mean that Mary was any better than Martha, but in this case Martha had made the wrong choice. God thought this was important enough to inspire Luke to put it into His Word so that we could understand this principle. Jesus is not saying that one should do no housework, but rather, that Martha's failure to follow the higher priority was doing damage to her character. There is a time to set aside the service of others in order to serve God.