"Chemistry" is literally a scientific field devoted to studying the composition of matter. Because part of that subject involves reactions between different elements and compounds, it has become a metaphor for human interaction. While a bit abstract, in that context it means those persons enjoy each other's company, share common interests, work well together, et cetera (unless it's specified that they have bad chemistry).
New words, one handy idiom, and a 2-minute quiz — delivered to your inbox to keep your streak alive.