The answer is simple. Hamas needs to say to Israel "We recognise your right to exist unconditionally. We're prepared to establish diplomatic relations with you and will guarantee your security. In return, we ask that you open the borders, help us establish basic services to an acceptable level and work with us to build lasting prosperity for the people living there. We still want a Right of Return but accept that there needs to be a pragmatic solution, with maybe some people able to return and compensation paid to others. We also want an agreement from other countries that Palestinian refugees can have rights of citizenship in those countries if they wish." Then the problem goes away.
Do you actually believe that?!?!
There are Israeli politicians demanding that Israel annexes the entirety of the West Bank. There are Israeli politicians that believe it is justified to kill all Palestinians, including civilians, because this is a “war between two peoples”. There are Israelis that are campaigning for the destruction of the Al-Aqsa mosque. There are fundamentalist Jews that believe it justified to murder non-Jews that live in their “greater Israel”.
I see a lot of criticism of Hamas here, some of it justified, but very little criticism from those same people about Israel’s own politicians, many of which hold equally extreme views. These politicians did not elect themselves. They represent the views of a large number of Israelis that will never accept any homeland for the Palestinians within the borders of a “greater Isreal”. Given the chance they would finish the job and exterminate every last Palestinian.
I’d highly recommend Louis Theroux’s Ultra Zionists documentary, which shows plainly the ideology of those Israeli extremists that represent a significant portion of the electorate. If it were as simple as you believe then this would have been solved long ago. The fact is that there is not a willingness on the Israeli side to give up any inch more than they are forced to (which right now is nothing). The only reason that they withdrew from Gaza was to prevent a “demographic defeat”.