Regioselectivity of electrophilic aromatic substitution in imidazo[1,2-a]pyrazine
You are on the right track. Pyridine and similar nitrogen analogs of benzene are deactivated with respect to the electrophilic aromatic substitution reaction. You are also right that a resonance structure can help explain the regioselectivity of the reaction on the five-membered ring.

Electrophilic attack at C–2 (bottom line) directly gives an intermediate with non-aromatic resonance structure 2a. Moving electrons around, we are able to draw an aromatic resonance structure 2b, but this structure also contains a non-octet atom (carbocation), repulsive neighboring positively charged atoms, and charge separation.



On the other hand, electophilic attack at the observed site gives an intermediate 3 that maintains aromaticity in the six-membered ring and complete octets in all atoms.



We can predict that the intermediate arising from attack of the electrophile at C–3 would be more stable than the corresponding C–2 substitution intermediate. Since this step should be endothermic, the rate of this step will be influenced by the stability of the resulting intermediate (Hammond's postulate). From there, we can proceed through the usual addition/elimination mechanistic sequence to get to the product.