This is what happens when you read things out of context. Quoting a verse without knowing what it precedes or succeeds can result in terrible transformation of the actual meaning .
The historical background of this surah is the following :
The series of events discussed in this surah are after the peace treaty between Muslims and the quraish tribe. By that time, pretty much of Arabia was under Islam and this treaty afforded further opportunities to Islam to spread it's influence in a peaceful manner. The Holy Prophet(pbuh) sent missions among different clans for the propagation of Islam. The result was that Islam grew to such an extent it made the older order of ignorance helpless before it. The jealous quraish were so exasperated that they broke the peace treaty and decided to encounter Islam in a decisive combat and a war happened.
So the verse you read is actually reflecting the state of affairs during a war and it is confined to that time only. Hope you understand now how reading things out of context can utterly alter the meaning.
if a book contains slay non-believers, it is a violent book?
here is the full verse:
"And when the sacred months have passed, then kill the polytheists wherever you find them and capture them and besiege them and sit in wait for them at every place of ambush. But if they should repent, establish prayer, and give zakah, let them [go] on their way. Indeed, Allah is Forgiving and Merciful." (Qur'an 9:5)
It may appear violent because you don't understand the context. here is the Explanation of 9:5 Surah Tauba 9 verse 5, 9:5
I will just copy paste it.
An Analysis of Al-Taubah 9: 1 - 28…
The first point that needs to be considered is the opening of Surah Al-Taubah. The opening of the Surah may be translated as:
“A declaration of the dissolution of agreements from God and His messenger to the idolaters with whom you have made [no-war] agreements. Thus, you [O polytheists] may freely traverse in the land for four months, but know that you shall not escape God’s judgment and that God shall surely humble the unbelievers. A proclamation [should be made] to these people from God and His messenger on the day of Hajj-e-Akbar, [declaring] that God and His messenger are no longer under any obligation toward these polytheists. If you repent, [O polytheists,] it shall be better for you but if you turn your backs [paying no heed], then know that you shall not be able to escape God’s judgment. Give these rejecters the glad tidings of a painful punishment, except those polytheists who have not dishonored their treaties with you and have not aided anyone against you. With these, fulfill your treaties till the appointed term. Indeed, God loves the righteous. When the sacred months are over, slay the polytheists wherever you find them. Arrest them, besiege them and lie in ambush for them.” (Al-Taubah 9: 1 – 5)
The Qur’an further says:
“How can there be any responsibility of these agreements on God and His messenger, except those with whom you made agreements at the Sacred Mosque? Thus, so long as they uphold their part of the treaty, you should uphold yours. Indeed God loves the righteous.” (Al-Taubah 9: 7)
A close look at the above verses shall suffice as evidence to the fact that the directive, “Arrest them, besiege them and lie in ambush for them” is given against those polytheists with whom the Muslims, under the leadership of the Prophet (pbuh), had entered into an agreement and who had disregarded this agreement and aided others against the Muslims. Obviously, these qualities cannot be generalized on all the polytheists of the world.
The Qur’an further says:
“Will you not fight against those who have broken their oaths and have conspired to banush the messenger? They were the first to attack you.” (Al-Taubah 9: 12)
Thus, a further qualification of those against whom the directive is given is that besides breaking their oaths with the Muslims, they conspired to banush the Prophet (pbuh) and were the first to attack the Muslims. It is obvious that the referred directive implies to take action against a particular people. It cannot be generalized to the whole world and to all times to come. The Qur’an further clarifies that the directive is mainly against those particular polytheists who were the custodians of the Haram – the Ka`bah. The Qur’an says:
“It is not becoming for these polytheists to manage the mosques of God – being themselves witnesses on their own rejection.” (Al-Taubah 9: 17)
An important point to remember here is that, according to the Qur’an , it is the special and specific position of the Rasu’l (messengers) of Allah, which renders the rejecters among his direct addressees “themselves witnesses on their own rejection”. The Qur’an tells us that the messengers of the Almighty, in contrast to Nabi’s (prophets), are not merely deliverers of God’s message. It tells us that a messenger of God is a sign of God’s final justice. When God sends his messenger among a people, these people are left with no excuse of rejection. The truth becomes as apparent for them as the shining sun. Consequently, if these people persist in their rejection, they are sentenced to one of the following two punishments depending upon their beliefs:
If they are polytheists (Mushrik), they are sentenced to death, as a punishment of their rejection. The Qur’an has presented the people of `aad, Thamud, Nooh, Lut, Musa etc. as examples of this category;
On the other hand, if these people are not polytheists, they are not sentenced to death, however they are forced to become subservient to the believers of the messenger. The Banu Israeel, after their rejection of Jesus (pbuh) were subjected to this punishment.
Keeping this brief explanation of God’s law regarding the rejecters of His Rasu’l in perspective it should be clear that the phrase ‘being themselves witnesses on their own rejection’ implies a particular people against whom the companions of the Prophet (pbuh) are directed to take the action.
As has been mentioned above, the polytheists among the rejecters of a messenger of God are sentenced to death. The implementation of this sentence may take two forms, depending on the condition of the believers :
If the believers are very few in number and if an Islamic state has not been created, then this punishment is directly implemented by the Almighty. This implementation normally takes the form of a natural calamity, like a flood, an earthquake, a windstorm etc. This has generally been the case with the rejecters of the messengers of Allah. They were punished by nature unleashed. The Qur’an , in Surah Al-Qamar, while addressing the polytheists of Arabia , at the beginning of the Prophet ‘s ministry, has referred to some of the more known among the rejecters of the previous messengers of God and has mentioned the consequences that they were subjected to face because of their rejection. At the end of the Surah, the Qur’an has asked the addressees of the Prophet (pbuh):
“[Why O polytheists of Arabia , would you not be punished in the same way?] Are your unbelievers better than these [previous rejecters of our messengers]? Or are you given immunity [from this punishment] in the Holy Scriptures? Do they say: We are a strong army [of men]? [Nay,] the army shall surely be routed and they shall flee turning their backs.” (Al-Qamar 54: 43 – 46)
Thus, the addressees of the Prophet (pbuh) were warned of the consequences of their rejection from the beginning of the Prophet’s ministry. They were informed that if they persist in their rejection, they shall face the same consequences as were faced by the rejecters of the previous messengers of God.
If a significant number of people accept the messenger of God and the messenger also succeeds in forming an Islamic state, then this punishment is implemented through the believers . This serves two purposes. Firstly, the rejecters are punished and secondly, the believers are tested for their truthfulness and the genuineness of their faith.
Keeping this point in perspective, if we consider Al-Taubah 9: 14 – 16, we see that these verses direct the companions of the Prophet (pbuh) to fight the unbelievers and inform them of the reasons for this directive. Let us take a close look at these verses:
“Fight them. God shall punish them [for their rejection] through your hands. He shall humble them, grant you victory over them and shall thereby heal the spirit of the believers and remove all rancor from their hearts… [This fighting against your own kith and kin shall be a test for the truthfulness of your belief in God.] Did you think that you would be left alone [and not tested for the truthfulness of your faith], while God has not yet determined those among you who fight [in His way] and take none as close associates except God, His messenger and the believers? [Remember that] God is aware of all your actions.”
Seen in this perspective, it should be obvious that the directives entailed in these verses are specific to the direct addressees of the Qur’an . They can, by no means, be generalized for all human beings and for all times to come.
Finally, if we look at Al-Taubah 9: 39 – 40, we shall see that in these verses, God has warned the hypocrites and the weak among Muslims that if they do not help the Prophet (pbuh) and fight according to God’s directives, they shall face the dire consequences of turning their backs. These verses also declare that whether the Muslims help the Prophet (pbuh) or not, God shall Himself help him and shall grant him victory over the rejecters. The Qur’an says:
“If you do not go to war [against these rejecters], He will punish you severely and will replace you by another people [, who shall help him]. You will not harm him in any way for God [is his protector and He] has power over all things. [Thus,] if you do not help him, God [will Himself help him, as He] helped him when these rejecters drove him out, when he was only the second among the two. When they were in the cave, when he said to his companion: ‘Do not despair, indeed God is with us’. God caused His tranquility to descend upon him and strengthened him with warriors that were not visible to you and [thus] He routed the words of the rejecters and exalted the word of God. Indeed God is mighty and wise.”
The ultimate result of the fighting regarding which the believers were being directed to participate in was also declared in this Surah. The Qur’an declared:
“It is He, Who has sent His messenger with His guidance and the True Religion that He may exalt it above all other religions [of Arabia], however much these polytheists may detest it.” (Al-Taubah 9: 33)
In the light of the above explanation, it should be clear that the Surah and the directives entailed in it are specific not only in their address but also in their implication.
I hope this helps. In case any aspect of my answer remains unclear, please feel free in writing back to me at your own convenience.
May the Almighty guide us all to the path of His liking.