This is an interesting question, I've never heard of Okinawa being questioned as necessary or not. Peleliu is now regarded as a complete waist of lives as the forces it was supposed to protect against no longer existed at the time of the Philippine invasion (now theres a campaign we could argue over the *military* necessity for).
But here's my take:
1. Okinawa was invaded a full 5 months before the bombs were dropped in anger, and a good 4 months before the Trinity test. So at the time of the invasion the bombs were not even a viable weapons system. And there were many that did not think the bombs would work, though most scientists at the time were reasonably sure they would.
2. Without a doubt Okinawa was the next step in the island hopping campaign that was to end with the invasion of Japan. And it was necessary to keep the pressure on the enemy, you can't just sit around for 5 months waiting on a weapon that might or might not work. Giving the enemy time to recoup.
So at the time, given the situation and the information available to US planners, yes the invasion was necessary.
In the absence of the invasion would the Japanese have surrendered? I don't know, but it certainly helped their decision along knowing that the Allies were *literally* knocking on their doorsteps and had actually taken pre-war Japanese territory. Not to mention the added attrition on her military caused by loses suffered during the campaign.
I'll go out on a limb and say that it would have taken more bombs than just the two that were dropped. Even after the loss of Okinawa and the dropping of the two bombs it took direct action by the Emperor to end hostilities. And even then some hard liners had the balls to attempt a coup.
BTW, and FWIW, I was born on Kadena AFB, Okinawa.