Probably going to be more fleshed out answers but as there is nothing here yet I'll give it a crack. I will say, regarding international law, it is usually power, not the letter of the law, that dictates an outcome and international law is a conflicted mess. You can find sources that probably back up both claims so justified is really a matter of opinion as well as if you accept the doctrine of pre-emption which all countries do not. But here is an interesting article regarding the history of preemption and the 6 day war is on page 94.
Israel ultimately argued that it was acting in anticipation of what it believed would be an imminent attack by Arab states. Its neighbors were signing defensive pacts, anti-Jewish rhetoric was on the rise (politically popular at the time), and military forces were mobilizing near its borders. And, if that was not enough, the closing of the Straits of Tiran was an act of war itself as it effectively blockaded some Israeli ports.
Egypt argued that they were amassing forces defensively out of fear from an Israeli attack and had sources (presumably USSR) warning them of possible Israeli aggression and the US State Department ambassador had said something similar. And while numerically smaller, the US knew the Israeli military was qualitatively superior to its surrounding neighbors and a premptive attack could cement air superiority. The report also said, "assessed that Nasser’s military presence in the Sinai was defensive, stating that “Armored striking forces could breach the UAR’s double defense line in the Sinai in three to four days and drive the Egyptians west of the Suez Canal in seven to nine days. Israel could contain any attacks by Syria or Jordan during this period"
In hindsight, even Yitzhak Rabin, who would later become Prime Minister, said the year following the ’67 war, “I do not think Nasser wanted war. The two divisions which he sent to the Sinai, on May 14, would not have been sufficient to start an offensive against Israel. He knew it and we knew it.” So an argument of preemption due to self defense is a lot weaker then many people seem to remember and might be outright wrong but you can still fall back on the blocking of the Straits as an act of war making it have a legal legitimacy.
So if you don't accept a political realist doctrine, you have to see if there is legal justification under international law. Was it preemptive? Probably not as both the US and Israel knew Egypt and its allies weren't a real threat. Was it preventative? Doesn't really matter in the context of international law as it falls under preemptive. Was it justified? Probably not under a doctrine of preemption but the blocking of the Straits gives it a legal justification if nothing else.
If he swings around, /u/tayaravaknin can probably give a better answer.
The question you're asking is multi-faceted, which makes it harder to answer.
Some argue for example that preventative strikes are not justified, while pre-emptive are. Some argue that neither are, because the necessary tests for a legitimate pre-emptive strike could never be satisfied.
That aside, I'll work under the usual framework, which is that a pre-emptive strike with solid qualifying factors can be justified, preventive ones cannot, and that responses to aggression are justified.
I'd argue, along with many others, that it was a pre-emptive strike. Hindsight affords us a situation that the leaders of Israel at the time simply did not have. They were told, for example, that they would win any war with the Egyptian, Syrian, and Jordanian armies. They were told that even if attacked first, they would win within 2 weeks. However, they were not so sure of the assessments, and were also not so sure they could sustain an initial strike. As such, Israel's leaders chose to pre-empt, fearing a strike that would cripple them or cause more undue harm than they could afford.
For a detailed look at the factors leading up to the war, you can always check out my post here. It's very long though, so I'll break it down into a short summary below, and also talk more about the theory of pre-emptive strikes.
A pre-emptive strike can be justified when it meets certain conditions:
Proportionality - Is the attack proportional to the threat.
Last resort - Have all other options been exhausted.
Proper Declaration - Have the authorities with the proper authority to make the decision declared the war, and done so publicly.
Probability of Success - Do you have a reasonable expectation that you will succeed, and this isn't futile hostility.
Right Intent - Are you going into the war with the right intention alone, not a greedy or self-serving one that is masked by "pre-emption" rationales.
Just Cause - Do you have a good reason to go to war at all.
A good paper describing the tradition briefly before going into one influential theorist's (Michael Walzer's) analysis and changes to the tradition can be found here [PDF FORMAT!].
Under this framework, Israel argued the following:
Proportionality - This would be a war of survival, and Israel was tiny. A pre-emptive strike to survive would be proportional.
Last Resort - Israel had waited over three weeks, during which time Egypt mobilized along the border in the Sinai, signed a defense pact with Jordan placing Jordan's military under Egyptian control (Syria had already signed a similar pact), and blockaded the Straits of Tiran, something that Israel said it would consider an act of war (and which could be, under international law) in a speech to the UN General Assembly in 1957.
Proper Declaration - Obviously, Israel's government was the proper authority and did declare war.
Probability of Success - Obviously Israel believed there was a probability of success, though how successful they were was a shock even to them.
Right Intent - Israel claimed its only motivation was defense, which would be legitimate. I'll get more into this in a bit.
Just Cause - Israel obviously claimed it had a reason.
Now there are some key points that people still argue about today. The first question is around the idea of last resort, which is one of the hardest to satisfy. The thing is, we cannot examine last resort with hindsight. We cannot examine whether or not Israel was going to be attacked and say "AHA, they had other options", we can only look at whether or not they believed they had other options, and made every effort to exercise them. Israel had already approached the United States and international community in the hopes of breaking the blockade of the Straits of Tiran, which did not occur. The United Nations had stationed peacekeepers in the Sinai from 1957 to 1967, under the UN Emergency Force (UNEF), which was removed by Nasser unilaterally. Israel saw the defense pact signed with Jordan, and saw mobilization along its borders. And so, having mobilized itself to attempt to deter Nasser, and seeing no end in sight to the mobilization, it had a choice. It could either send its troops home and hope for the best, or keep them out there and leave the economy ground to a halt. After all, Israel's small population meant that to field a deterrent force and mobilize so many reserves would draw heavily on the country's workforce, harming it economically. It's third choice was pre-emption: make a war short and sweet, end the mobilization, and force peace. It chose the third, seeing no other option available. Even if there was one, or an attack was not actually imminent, the belief and imperfect information that exists in the world meant that the fear was well-founded, which would satisfy a reasonable pre-emptive strike doctrine.
Another point of contention is right intent, which is the other main point. People argue that Israel knew it had other options, but that it went into the war with self-serving motives. This is often easy to claim, based on the settlement growth that resulted from occupying the West Bank and Gaza, and the feeling that Israel was gaining huge amounts of viable land. There was also the feeling that Israel was going to war to claim the Old City of Jerusalem, which was under Jordanian control.
The most prominent claims here are those of Menachem Begin, who was prime minister of Israel for the first time in 1977, and those of Mordechai Bentov, a housing minister. First, Bentov.
Bentov claimed that there was no danger of extermination, and that the whole war was "invented of whole cloth and exaggerated after the fact to justify the annexation of new Arab territories". However, Bentov was a housing minister, and the only one who seemed to believe this in the Cabinet. We can never know what everyone intended, but Bentov being the only one to speak out as such (besides Begin) speaks volumes on the subject. Bentov also was a member of the far-left socialist party, Mapam, and he argued that there were other options they could have explored to settle the situation. Obviously, he was an outlier in the overall view of the government (and may not have even served in the IDF), all of which appeared to believe that he was wrong and that delays would only harm the Israeli economy or open it up to attack.
The next case is Menachem Begin, who in 1982 famously said:
In June 1967 we again had a choice. The Egyptian army concentrations in the Sinai approaches do not prove that Nasser was really about to attack us. We must be honest with ourselves. We decided to attack him.
However, many people follow this by ignoring what he said next, which was the following:
This was a war of self-defence in the noblest sense of the term. The government of national unity then established decided unanimously: We will take the initiative and attack the enemy, drive him back, and thus assure the security of Israel and the future of the nation.
We did not do this for lack of an alternative. We could have gone on waiting. We could have sent the army home. Who knows if there would have been an attack against us? There is no proof of it. There are several arguments to the contrary. While it is indeed true that the closing of the Straits of Tiran was an act of aggression, a causus belli, there is always room for a great deal of consideration as to whether it is necessary to make a causus into a bellum.
What he means here is difficult to understand. He obviously sees the closing of the Straits as justification for war, but he argues they could've gone on waiting and hoped for the best. Obviously, Israel's leadership didn't believe this was a good idea. But does he mean it was preventive? Does he mean that last resort was satisfied, and any more satisfying would be unrealistic? Depends who you ask. He wasn't in charge, at any rate, though he was privy to the details. Even so, Israel doesn't believe that it was anything other than legitimate self-defense and pre-emption on that front, and that the lack of possible attack while mobilized didn't mean there was an alternative like sending troops home, or letting the economy flounder: most argue actually that had they sent the troops home, Israel might've invited attack.
Another interesting case is brought up in another comment, a statement by Yitzhak Rabin:
I do not think Nasser wanted war. The two divisions which he sent to the Sinai, on May 14, would not have been sufficient to start an offensive against Israel. He knew it and we knew it.
But here's the thing: the statement is incomplete as well. Rabin was talking about the two divisions sent into the Sinai on May 14, but the war didn't begin until June 5. The time differential is important here. You see, as I put it elsewhere:
The problem is, the UNEF peacekeepers were evacuated after that. The blockade was initiated after that. More divisions were put in place after that. In fact, by May 20 (before the blockade), more than 6 divisions were in place.
Also, a look at the full quote is helpful. Those who quote this typically change around a few words to lie. What Rabin said, as you can read in this book on pg. 18, was:
We did not think that Nasser wanted war.
The difference is crucial. Did not think shows change. Do not think means no change.
That aside, I think it's important that we consider more than just that small portion which doesn't accurately reflect Nasser's moves.