Benjamin Netanyahu, the longest-running Israeli prime minister, could be ousted in days after rivals agree to work on unity government