According to the Oxford English Dictionary, while there are some cases in which I and Y can be used to represent the same sound, it is not always the case. They write that there are three situations in which a Y is used:
About the middle of the 13th century y began to be used to represent the voiced palatal spirant /j/ , taking the place of the character ȝ (called yogh n., q.v.) in one of its values. -- This use is retained in words like "year", "yet" and "young"
Another value of y arises from the assimilation of y and þ, the runic thorn (see th n.), which had become indistinguishable from each other in some MSS. of the early 14th century (e.g. the Cotton MS. of Cursor Mundi). After 1400 þ fell more and more out of use, and in some scripts was represented only by the y-form in the compendia ye, yt or yat, yei, ym, yu = the, that, they, them, thou, and the like, many of which continued to be extensively employed in manuscript in the 17th and 18th centuries. -- This use has largely fallen out of common practice
In later (West Saxon) Old English, y was written alternatively for i, e.g. as representing older ie, as in cyle, ongytan, yld, for ciele, ongietan, ield
In its third use, I and Y were interchangeable into Middle English, but after that orthographic rules were put into place, and Y was only used in the following cases:
(i) for final i-sounds, as in fly, family, daily, destroy (formerly spelt also flie and flye, familie and familye, etc.), only alien words being spelt with final i;
(ii) in Greek words, representing υ, as in hymn;
(iii) before i, in inflexional forms of verbs ending in y or ie, as flying, lying, tying, not fliing, etc.;
(iv) in the plural of nouns ending in y preceded by another written vowel, as boy boys, ray rays, alley alleys, money moneys (but monies is still common, and vallies, monkies, etc. were equally so until recently).
So in some instances, I and Y could be interchanged because they can represent the same vowel sound. However, there are now rules about when Y should be used to present this same vowel sound at all.