For cells not on the boundary: dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + grid[i][j]. 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[m-1][n-1]. The transition is the core of any DP solution. You can solve this in space by overwriting the input grid in place.