There are two questions here. One is whether the Osirak reactor was for peaceful uses or not. The other is whether there were good reasons for Middle Eastern states to build nuclear reactors.
First, it's important to keep in mind that the work on Osirak did not start in 1981. The Iraqi nuclear program began in 1956 as part of the global Atoms for Peace movement, but after the Baathists took power in 1968 the interest accelerated. In the early 1970s there was a push towards keeping a nuclear weapon option open. A big push came in 1973 during the Oil Crisis, which spurred several other nuclear programs in the region (including Iran) and the world, and encouraged the Iraqis to reach for an ambitious program that would include mastery of the entire fuel cycle. In 1980, Saddam had become president and decided that the ultimate goal would definitely be a nuclear bomb.
Osirak, however, wouldn't have given them that. What it would have given them was the experience of running a larger reactor and doing some small-scale handling of plutonium reprocessing. But it was not quite large enough to be useful in making enough plutonium for weapons on a useful time scale, and the design of the reactor was deliberately made proliferation resistant by the French (it would have been very difficult — not impossible — to produce plutonium in significant quantities with it). So it's not quite what it is often made out to be.
There were completely genuine reasons for oil-rich Middle Eastern countries to pursue nuclear power programs in the 1970s. There were also pretty good reasons for countries who were non-aligned or opposed to a (newly-nuclearized) Israel to want weapons, as well. Many of the nuclear power programs in these sorts of countries were "dual use" to some degree — an attempt to get Western assistance in building up a peaceful program so that, at a later time, they could take that knowledge and apply it towards developing weapons programs if they chose to.
Osirak was a reactor that was ultimately intended to generate electricity, but it was also meant as a way of acquiring "know-how" that would potentially later lead to a bomb. The Israeli claims that Iraq was "unambiguously" going to product plutonium for weapons at Osirak have not stood the test of time, however.
The consequence of bombing Osirak, as an aside, was that Iraq intensified its weapons effort, but this time looking at a uranium enrichment route. Within the field of security studies, this is often seen as a different sort of cautionary message: you can accelerate an enemy's nuclear program if you make them feel that said program is threatened.
A great overview of the history of Osirak, and what we now know about it, and how this complicates some of the earlier accounts of it, is Målfrid Braut-Hegghammer, "Revisiting Osirak: Preventive Attacks and Nuclear Proliferation Risks," International Security 36, no. 1 (Summer 2011), 101-132.
U/restricteddata has an amazing answer that covers a lot of what I was going to say as well as some things I would have been unable to cover.
I would add that for a modernist, Ba'athist regime like Saddam Hussein's the operation of a modern nuclear powerplant served political purposes internally and externally.
The nuclear power plant would have served multiple purposes internally: it would show that Ba'athists were more effective in modernizing Iraq than the previous Royal regime but it would also cement Hussein as a more effective Ba'athist leader than his predecessor, General Ahmed Hassan al-Bakr. The plant would attract scientific minds (keeping the brain drain from worsening in Iraq), provide reliable electrical power necessary for later ambitious projects (though how much of that power it could meet is debatable), and most importantly it would accrue accolades to Saddam Hussein personally as the Arab world leader who brought nuclear power to Iraq. Remember, Hussein has only been in power since 1979 and hasn't solidified his cult of personality yet.
Externally, it puts the superpowers on notice that Iraq is more than a pawn. It more importantly lets Israel know that Iraq is to be taken seriously. Would it produce nuclear weapons by itself? That, I think, is irrelevant for Hussein's purposes; the illusion of power is important at this point.
Honestly, it is my assessment that Hussein was taking a cue from another charismatic Arab leader; Gamal Abd al-Nasser. Nasser basically B.S.ed the Soviet Union into building the Grand Aswan Dam. It didn't provide the benefits Nasser bragged it would but it showed that Egypt (and more importantly Nasser) were effective leaders.
Don't forget, Ba'athism is a response to and in dialogue with Nasserite Pan-Arabism. The movements in the 1950s and 60s were rivals (coincidently Hussein was immersing himself into Ba'athist rhetoric in this period, so he would have been very much influenced by these conversations even though by 1980s Pan-Arabism is all but DOA).
Nuclear weapons and the other in the Western imagination Hugh Gusterson Cultural Anthropology 14 (1), 111-143, 1999
Saddam Hussein: The politics of revenge Said K Aburish Bloomsbury Publishing USA, 2000