AUL was warned about the danger which he faced in going back to Jerusalem. He had enough sense to know that it was dangerous, but he was also told this by revelation. In fact he was told at least twice (Acts 21:4 & 10). It seems obvious that Paul was not obligated to go back to Jerusalem. Then again, it certainly does not appear that he was forbidden either. In fact, once Paul had accomplished his aim, God encouraged him emphatically in a personal revelation (Acts 23:11). Anyway, back to the beginning of this story: when Paul got to Jerusalem, he reported to the leaders of the church there concerning what God had been doing among the Gentiles. The core of the church rejoiced at his report, understanding what God was doing. However, they also anticipated that there was tremendous potential for trouble from some of the other believers in town (Acts 20:21). Note that it was believers that threatened Paul initially. How sad! And, how hard that must have been for Paul! He loved his Jewish brothers so intensely. But he had been preaching liberty among the gentiles and to the Jews who lived among the Jews. So, Paul and some of the church leaders made what preparations they could to try to offset the danger. Basically, they wanted to send a message: Paul was still orthodox in his practice of Judaism. They failed. That is, they failed in their attempt to pacify all the Jews. They did not fail to honor God though, and they did not fail in their attempt to continue to propagate the gospel.
About a week after Paul had arrived in Jerusalem, some Asian Jews started a riot. This lead to Paul being removed forcibly from the temple. In fact, they prepared to kill him (Acts 21:31). As they were beating him, he was rescued by a captain with soldiers and centurions (Acts 21:31-32). Even with this rescue/arrest, the soldiers had difficulty transporting Paul to a secure place where he could be detained while inquiry was made concerning the riot and his role in it (Acts 21:35). Miraculously, just as the soldiers got Paul to the safety of a castle, he obtained permission from the captain to speak to the mob.