Jesus was a hunted man so he “left the state” to keep away from the local authorities. The complication was a festival He should go to but it was back where he was a “wanted man.” Not that there were “wanted” posters up with drawings of Jesus on them but the authorities were looking for Him. He was in danger of being killed.
So He was out of state spending time with his family. His brothers knew he was getting popular and wanted him to get even more popular. They said,
“Leave here and go to Judea [to the festival] …. For no one who seeks to make a reputation for himself does anything in secret. If you are doing these things, show yourself to the world.” (John 7:3-4)
It was good advice. The historian Craig Keener says,
From the standpoint of general ancient political theory, the advice of Jesus’ brothers is correct; …. Most teachers taught in public places. Frank or open speech (v. 4) was considered virtuous, secret acts deceitful. (Keener Jn 7:3)
Though they were right about being virtuous and about making a good reputation for himself, Jesus knew they were wrong…good advice but wrong for him. The danger was too strong even though his popularity had just declined when, as a result of on of his sermons (recorded in John chapter 6) many of his followers “withdrew and were not walking with Him anymore.”
But what was the danger? Was it being killed? No. He had come to earth to do that, to give his life. The danger was being out of God’s timing, his plan. If Jesus went to the festival with his brothers then he would have been captured then. So he told his brothers, “My time has not yet arrived, but you are ready at any opportunity!” (John 7:6) and “…my time has not yet fully arrived” (John 7.8).
Jesus did not let good advice for popular steer him away from God’s plan. At this point that plan was not about finding popularity, that was in the plan but for much later (Phil. 2.10-11). It was all about following God’s plan for his life and the danger was in not following that plan.
Jesus later says he followed God’s plan, “so that the world may know that I love the Father, I do exactly as the Father commanded Me.” (John 14:31).