It was an accident that was bound to happen.

Literal

Happen-[classical-should-べくして] happened accident was-[copula-past-だった].

起こるべくして起こった ('that was bound to happen, that happened as it was meant to') is a set fixed expression using the classical べく (attributive of べし, 'should') + して ('doing, while'). The full pattern [verb plain]+べくして+[same verb past] means 'X happened just as it should have,' implying inevitability. A fatalistic way to describe accidents foreseeable in hindsight.