Might be a dumb question...

I should know this because ive had this before in my previous pregnacy. But what exactly is the rhoGam shot for and what is it preventing? I just seen a post about it and i realized I honestly dont know anything about it, just that Im suppose to get it.