If I understand it correctly: Canadian raising is a phenomenon that, in many AmE speakers, alters the pronunciation of /aɪ/ before voiceless consonants. (The Canadians also have it in /aʊ/.) This leads to (say) ride and write having very different vowel sounds, with the diphthong in the latter starting more closed. As Wikipedia states, there are some exceptions to the usual "before voiceless consonants" rule. For instance, Canadian raising is unaffected by flapping; hence raising still occurs in writer even when the /t/ gets pronounced as voiced [ɾ]. This leads to an odd phenomenon: for some speakers (including myself), writer and rider have the same consonants but different vowels. (See also this answer.)
Then there are the weird exceptions. "Listening to Writers and Riders: Partial Contrast and the Perception of Canadian Raising" found that spider was raised by about 34% of "raising participants" in the US North, even though there a voiced /d/, rather than a voiceless /t/, is being flapped. "The Spread of Raising: Opacity, Lexicalization, and Diffusion" found that all of the 11 speakers they sampled had the raised sound in both spider and cider. This Linguistics.SE answer suggests that this is not uncommon.
For me, spider and cider indeed have the same vowel sound as writer, not the same vowel sound as rider. But this doesn't affect spied, side, or insider, so this doesn't seem to be related to the surrounding consonants. The first paper linked above argues, partly on this basis, that the raised sound "is becoming lexicalized and possibly emerging as a new phoneme"; the Linguistics SE answer shares that opinion.
But: why those two particular words, and few others? What's so special about spider and cider? Neither of those two papers seems to have an entirely definitive answer as to why spider and cider get raised when (say) rider doesn't.
If I'm understanding latter paper correctly, it seems to posit (in the second paragraph of section 3.4) that this phenomenon might occur partly because raising can occurs before [ɾ] in some words (writer) but not others (rider); this can make it hard for learners (children, in this case) to determine where to perform raising before [ɾ], particularly when the [ɾ] is morpheme-internal, as in spider and cider. That seems odd: it indicates that the replacement of one voiced consonant by another voiced consonant has resulted in a sound change that normally occurs before voiceless consonants.
Do I have that right? Is there some deeper reason why spider and cider are getting affected in this way?