"I thought that he ate the food."
Translation:Cheap mé gur ith sé an bia.
The short answer is history. Please continue reading for a longer answer.
In forming the past, among other tenses, the conjugated verb was prefixed by "do", and still is in some dialects. This caused lenition of consonants or the rendering of “do” as " d' " before verbs beginning with a vowel or fh.
I refer you to a more detailed grammar for a fuller discussion of when to use either form. but it depends entirely on the effects of the preceding grammatical particle e.g. a, ar, and, as such, the type of clause.
Addendum: see under the past particle for do and under direct and indirect relativa particles for examples of its usage and omission. http://nualeargais.ie/gnag/part.htm#verg
Precisely. Just as an is an interrogative particle that indicates that a verb is to be treated as a question, and ní is a negative particle that indicates that the verb is to be negated, do was a particle that indicated that the verb was to be in the past tense. Do lenited, which is why past tense verbs are lenited, but, for the most part, the particle itself has disappeared, except before verbs that start with a vowel. (do is still sometimes used as a past particle in Munster Irish - you might encounter do bhíos instead of bhí mé, for example).
But you never have two particles before a verb, and gur is already a past tense form, so gur replaces the d' before a verb that starts with a vowel.