Grief is a reaction to loss that is observed across human cultures and even in other species. While the particular expressions of grief vary significantly, universal aspects include experiences of emotional pain and frequent remembering of what was lost. Despite its prevalence, and its obvious nature, considering grief from a normative perspective is puzzling: Why do we grieve? Why is it painful? And why is it sometimes prolonged enough to be clinically impairing? Using the framework of reinforcement learning with memory replay, we offer answers to these questions and suggest, counter-intuitively, that grief may have normative value with respect to reward maximization. We additionally perform a set of simulations that identify and explore optimal grieving parameters, and use our model to account for empirical phenomena such as individual differences in human grief trajectories.