I always just assumed it was simply because it was a last-ditch effort.
But I just Googled it, and someone on Reddit pointed out: "Hail Mary full of Grace."
Groan... Actually makes me like the book a little less than I already did. (Edit: Which I know is against the grain here, as evidenced by the downvotes for not liking the book.)
Also, the prayer referenced in this idiom starts off as "Hail Mary, full of grace" and the main character's name is Grace.
edit: beaten by 6 min.