It has to do with aglutination of I am, you are, he/she/it is. To say 'I am good'= 'iyiyim', therefore 'I was good'= 'İyiydim'. It leaves a grammatical continuity between the present and the past. 'It was good'='iyiydi'. 'You were good'='iyiydin'. As you can see the y is used to separate words with any vowel endings from 'im' in the present, but it us also used to separate all situations in the past here a word has a vowel ending.