Diminished 7th chords actually come from the 7th note of the minor harmonic scale.
They can also be made from the diminished scale. The diminished and the diminished 7th are the only chords that can be made from the diminished scale.
There may be other sources that I’m not aware of but that won’t matter for now.
The diminished 7th can be used as a passing or connecting chord
Diminished chords connect subdominant chords. The subdominant chord is the IV chord of major scale
To do this you could use the diminished chord with the same name of the chord your on or the same name of the chord you are entering
So in the key of C if you were playing a C chord and the next chord was an F you could connect the two with a C or F diminished or diminished 7th chord
Here we use the note of the chord we are leaving
C to F with a C diminished passing chord
Here is the one using the chord you are entering. I prefer the sound of this one better
C to F with an F diminshed passing chord
You can also connect chromatically. When you have two chords a whole tone apart you can use a diminished or diminished 7th chord using the in between note
C to D minor 7th with a C sharp diminished passing chord
Remember these ideas also work for lead ideas. You can use the diminished scale to connect two chords, you don’t necessarily have to use chords
Here’s another example using the last C to Dm7 change but no diminished chord just C diminished scale notes
C to D minor 7th progression passing tones from diminished scale
The diminished 7th has another use. It can be used to replace a dominant 7th chord
To do this you would use a diminished 7th chord 1/2 step higher than the chord you want to replace.
If you want to replace a G7 chord (G B D F) you would use an A♭dim7 (A♭ B D F)
The diminished 7th has the 3, 5, 7 of the G7 chord. The A♭ would be a flatted 9th.
So even though you are using a diminished 7th chord you are replacing the G7 with a G7♭9 no root chord.
This works good in a ii V I progression allowing a chromatic drop of the bass line for this progression.
Two Five One Progression in the key of C