For cells not on the boundary: dp[][] = min(dp[-1][], dp[][-1]) + grid[][]. You pick the cheaper path (from above or left) and add the current cell's cost.
This greedy choice at each cell gives the global optimum because of optimal substructure. The answer is dp[-1][-1]. The transition is the core of any DP solution. It defines how the answer for the current state depends on answers for previous states. Getting the transition right is often the hardest and most rewarding part.