Hamas knows exactly what they're doing. They launch rockets at Israel and Israel's not going to stand by and let anyone do that without some sort of response. But Israel isn't going to send soldiers, that's asking for too much trouble for them in any regard (people would cry "Invasion!"). So they use airstrikes, the single most easiest way to attack. Its also the worst way to attack in an urban setting. Collateral damage is pretty much guaranteed, and anyone who dies from it is instantly a martyr and ratchets up sympathy from the world. It's win-win for Hamas.