Because you’re BB and out of position, I’d like to see a raise pre-flop. A limp makes more sense from late position.
Given the way the hand played out, a fold is smart, but that’s easier said than done. In the long run I see it as the smarter play because you can only use the info you have at the moment, and our opponent’s raise is clearly telling us he has a straight. Your odds of improving on the river aren’t great, so even though in this instance you got a sick river, I like the fold.