(1) surely..., but ~ (2) should have ~
Expresses pity or reproach about something that surely was or should have been the case, but wasn't.
This pattern combines the conjecture だろう (probably) with the particle に, which here carries a sense of contrast or disappointment. You use it when you imagine what was likely true or what should have happened, and then point out that reality fell short. It often carries a tone of sympathy (e.g., feeling sorry for someone) or mild reproach (e.g., criticizing someone's choice).
だろうに is a written or formal-spoken pattern, common in novels, essays, and formal speech. In casual conversation, you would more likely use のに or はずなのに. Because it sounds a bit literary, using it in everyday chat can feel stiff unless you are joking or being dramatic.
The key is that the speaker is making a guess about a past or present situation and contrasting it with what actually happened. It is not used for future possibilities; the focus is on reality that has already unfolded.