You might find this thread useful in answering that - When to use and when not to use 'i ' as a preposition before a verbnoun
However, it’s also worth pointing out that sometimes the i is there because it ‘goes with’ the preceding verb e.g. dwi’n moyn ymlacio compared to dwi’n mynd i ymlacio … the i in the second one is because mynd is almost always followed by an i.
Edit - haha, Hendrik beat me to it!