As with every other game, good players get rewarded, while not-so-good players get punished in accordance with their performances. Thus, when you drop your accuracy by not hitting the notes in time, the game punishes you by lowering your HP, eventually leading you to the fail screen. Other than that, you can always toggle the No Fail mode on, if you wish to continue playing without worrying about your HP bar.
osu!mania has a similar notion here, as well. However, those two modes are quite different in terms of gameplay elements, so it's hard to judge if the same HP conditions applied to the other.
Since osu! has a relatively long learning curve, I can understand that you are struggling for the time being. The key to the problem is to keep playing, then you will notice the improvement.