According to Webster, agree comes from Latin ad + gratus. However there are other words such as aggregate and aggression that also come from ad + [something], and these words are spelled with a double "g" while agree only has a single "g". Why does agree have only one "g"?
Per the online etymology dictionary the word comes to English via Old French agreer which was derived from a gré literally to one's liking.
This did come from ad gratum but not without a lengthy trip through France.
The double-g wasn't present in the phrase a gré hence not brought over.
Actually, it is all a bit more complicated. In Middle English we find agry, agree, but also aggre, aggree etc. In Middle French too we have agrer, agreer, but also aggreer etc. So the decision to spell it with just one g in Modern English and Modern French is rather arbitrary. Mediaeval Latin aggreare is a back-formation from French.