The problem is kinda complex, so this will basically be brief and not 100000% accurate. After the 3 Israeli boys were kidnapped and murdered, some ******** [assumedly Israeli] kidnapped and murdered a Palestinian boy. Hamas are losing support on the ground, and are completely out of allies internationally; even Iran has turned their back on them. And you have Salafi (ISIS type, real bad eggs) forces/influences/support starting to rise in Gaza. So Hamas need to gain some sort of support, or risk losing control. Meanwhile you have these Salafi types [who are not openly affiliated with Hamas and outwardly hate them/could very well hate them privately] gaining support, firing rockets at Israel, and basically showing that 'extreme radicalism and terror' can get results. So Hamas can't afford to be seen as weak basically, internally. They need to find some external and internal support. So they are forced to escalate.
Meanwhile in Israel, the political system is basically kinda transient - if you're not seen as good enough at defending, you're kicked out. So they have very little political capital to not respond, and importantly too, not to get soldiers kills. Meanwhile, they have to be seen as tough on Hamas, whilst obviously they don't want to defeat them and cause a power vacuum. Meanwhile they have very little current human intelligence in Gaza [the bedouin, druze, and israelis make up the majority of humint and that doesnt work for obvious reasons in gaza]
-----
So you're left with Hamas escalating with these rockets, or letting these rockets be fired and attributed to them.
Hamas living in a very urban environment, whereby the only way other than airstrikes would be ground forces.
Israel are forced to respond with airstrikes
Hamas respond further, when they feel they haven't gained enough public opinion
Israel sends in ground troops, more people, and troops die.
Ceasefire announced whilst both sides hate each other that little bit more.