Theory does come afterwards, however if you're looking for a connection to understand why stuff works and sounds good, theory is not totally unhelpful.
Here is one way to see a connection and it depends on the context:
Ab7 is the tri-tone substitution for D7 (dominant of Gm).
Then Ebm7 is the ii of that chord.
I guess you could call it the ii-V of the tritone, if you need to express it.
Gm goes naturally to EbMajor. Maybe your Ebm is a minor sub because the melody called for it.
Although we'd really need the melody to properly analyze this, and this might not apply in your case, another way to look at it (warning: more theory coming up) is that you are trying to get from G minor (as the tonal center in the verse) to BbMajor where the song 'starts'. They are pretty far away actually since that G minor has a sharp. F#. Playing through Ebm7 and Ab7 adds more flats than Bb Major has so you are kind of going past Bb Major in the cycle of fifths and then coming back. That is really what that chord motion sounds like anyway. It sounds like you are going too far in the other direction, or like coming at Bb from below, which makes the resolution satisfying. I'm assuming you use Ab7 to get to Bb, but if not maybe give it a try.
And please don't quote me on all that theory.
So why does Ebm work? It's connected to Gm in all of those ways.
But ultimately, melody implies harmony. So you just need a strong melody leading to a note (maybe not even a common tone) in a chord "outside" of the key and then you can go anywhere. That's probably the simplest way to explain it.
Just do something that sounds good. (quote me on that). You can see how all that theory becomes somewhat meaningless after a simple statement like that.
Gm to Ebm directly is probably somewhat less common, but one song comes to mind: Dindi by Antonio Carlos Jobim. On the bridge. (But that's in Eb Major, so maybe functioning a bit differently there). But the melody is at work there with a nice common tone.
There's a million songs that go from BbMaj to Ebm7. "iv" minor. It's one of my favorite chords.
Hope that was helpful.