In my story, there is an immortal peaceful type iv civilization that has spead across the universe, helping other species to advance and to bring peace. They have left behind their need for war or violence and they despise any sort of conflict. And yet, despite being so peacefull a vast majority of them constructs weapons, like plasna rays or black hole bombs and even some more primitive ones like swords. Yet they never seem to use them in any hostile way. Why? Why, would a species that is so peacefull want to construct weapons. Could they be doing it as a form of art? Could they be making them for the sake of science? Or could they be using them as "toys". Could they be fighting with others in a friendly way (without causing harm to the other) as a sort of entairtainment, or some other reason entirely?
Si vis pacem, para bellum
Just because they're at peace now, doesn't mean they always have been at peace, nor that they always will be at peace. They know what war is, they have been at war, there is a risk that they may again encounter a species who wish to be at war with them.
'For fun' would probably be a good enough reason.
It's good enough for us at least. Plenty of people in the modern world have very little desire at all to go to war or kill anyone, and yet those same people will happily play violent videogames, collect swords to hang on their wall (or take to re-enactments!), or go target shooting.
If they're far enough along the technological road, then their 'target shooting' hobby weapons could be fearsome indeed to a less advanced species. If you want to make it seem a little less flippant, then describing it as 'curiosity' rather than 'fun' would do the trick ;)
If the technological disparity is great enough, then even their tools might qualify as deadly weapons to other civilisations. Think about how a stone-age society might react to a chainsaw...
Not very interesting perhaps, but what about experimentation for the sake of research? Ah, that's "for the sake of science" as you mentioned. The argument could be made that, if "necessity is the mother of invention", then you might want to at least simulate wars as a means of competition, for scientific progress.
I'm not saying that's the only way to spark competition, but it's one way among many.