Why use a lagged DV as an instrumental variable? I have inherited some data analysis code that, not being an econometrician, I am struggling to understand. One model runs an instrumental variables regression with the following Stata command
ivreg my_dv var1 var2 var3 (L.my_dv = D2.my_dv D3.my_dv D4.my_dv)

This dataset is a panel with multiple sequential observations for this set of variables.
Why is this code using the lagged values of the DV as instruments? As I understand it (from digging into an old textbook), IV estimation is used when there is a problem because of a regressor being correlated with the error term. However, nothing is mentioned of choosing lags of the DV as instruments. 
A comment on this line of the code mentions "causality". Any help in figuring out what was the goal here would be most welcome.
 A: Edit: Given the clarification on the stata code provided by Andy W below, i changed my answer to better adress the question. You will find the old version of my answer below the current one. 
It seems your code is a clumsy attempt at DIY'ing the Arellano-Bond estimator (assuming ivreg estimates with 2SOLS). You can find more details on the use and logic of the A/B estimator in this nice review paper as well as in this broader introduction. 
In a nutshell and within 3 lines: although the A/B estimator is indeed an (generalized) IV estimator, it is not used to address any issue of causality. The IV's in this context are used to provide efficient estimation of the AR coefficient in the context of panel data. 
I would recommend against re-inventing the wheel here, and instead using ready made toolbox to perform such estimations. For stata, you can use the XTABOND2 (or XTABOND if you are running STAT11) package.

old response:
A simple example will help you here. Suppose you have two variable $x_t$ and $y_t$ sampled over time such that the correlation between $x_t$ and $y_t$ is very high. You would like to make a claim about $x_t$ causing $y_t$ but unfortunately there is a very good competing and credible theory under which $y_t$ causes $x_t$. 
To disentangle the two competing models, you regress $y_t$ on $x_{t-1}$ (instead of $x_t$). Often, you will lose in precision (i.e. the correlation between variables sampled at different times is usually lower than the correlation between variable sampled simultaneously). 
The way the two competing models - $y_t\leftarrow x_{t-1}$ and $x_{t-1} \leftarrow y_{t}$ - are now disentangled is that, presumably, there is not a good theory under which an $x$ from one period ago can be caused by a current $y$ ('the past cannot be caused by the future'), excluding the second sense of causality.
Note that the use of this trick is only valid if both variables (the $y_t$ and $x_{t-1}$ are stationary $I(0)$).
A: I don't know Stata, so I can't comment on the specific model.  But the use of lagged variables is a fairly common approach when dealing with simultaneity bias in general and creating instrumental variables in particular.  
Say you have a feedback between two variables in your model: the independent variable (such as price) and the dependent variable (such as quantity).  Then both are endogeneous (their causes arise from within the model) and perturbations to the error term will affect both variables.  
To solve this, you want to make the independent variable (price) exogeneous so that perturbations in the error affect only the dependent variable (quantity).  This is accomplished by creating new exogeneous variables by regressing the other exogeneous variables in your model on price.  These new exogeneous variables are your instrumental variables (IVs).  The IVs are derived from exogeneous terms and thus not correlated with the error.
But to do this, you need to figure out which variables are exogeneous so they can be used to derive the IVs.  We can note that lagged variables "occurred" in the past and thus can't be correlated with the error in the present.  Lagged variables are thus exogeneous and become convenient candidates for deriving IVs.  (However, note that the preceding argument fails when the errors are autocorrelated.)
A good introduction and reference to this is Introductory econometrics: a modern approach by Wooldridge.
A: For those not familiar with the following code snippet from Stata the OP provided
ivreg my_dv var1 var2 var3 (L.my_dv = D2.my_dv D3.my_dv D4.my_dv)
this equation can be read as
$Y_t = \alpha + \beta_1 (Var1) + \beta_2 (Var1) + \beta_3 (Var1) + \beta_4 (\tilde{Y}_{t-1})$
where $\tilde{Y}_{t-1}$ is estimated by 
$\tilde{Y}_{t-1} = \alpha + Z_1(\Delta^{2}Y_t) + Z_2(\Delta^{3}Y_t) + Z_3(\Delta^{4}Y_t)$
(i.e. the first stage of the IV equation is within the parenthesis in the Stata code)
The deltas represent second, third, and fourth order differences, and they are used as excluded instruments to estimate the lag of the dependent variable. 
In Stata code, the L. indicates lagging that variable by $t-1$, and D. signifies first order differences of that variable, and hence D2. signifies second order differencing.
Intially I could not think of any logical reasoning why someone would do this. But Kwak pointed out (referencing this paper) that the Arellano-Bond method uses the differences as instruments to estimate the auto-regressive component of the model. (Also intially I had assumed that the differences would only have an effect if the series is non-stationary, which Bond states in that linked paper the differences will only be weak instruments in the case the series is a random walk, on pg. 21)
As suggestions on further reading material as introductions to instrumental variables,
Another poster in this response (Charlie) linked to some slides he prepared that I like and would suggest are worth looking into for an intro to instrumental variables. I would also suggest this powerpoint a professor of mine prepared for a workshop as an introduction as well. As a last suggestion for anyone instrested in learning more about instrumental variables you should look up the work of Joshua Angrist.
Here is my initial answer

While I agree with everything that Kwak and ars have stated, I still can not think of any reason why someone would use the differences of the dependent variable as instruments to estimate the lag of the dependent variable (if people do not know Stata code, the L. indicates lagging that variable by $t-1$, and D. signifies first order differences of that variable, and hence D2. signifies second order differencing).
In all applications I have seen, people use the lag of independent variables as instruments to estimate the lag of the dependent variable (for reasons ars talks about). But this is based on the assumption that the lagged independent variables are exogenous to the error term in the time period they are being applied. 
I do not know of any reasoning in which the differences of the dependent variable would be considered exogenous. As far as I'm aware it is not accepted practice to difference only one side of the equation, and would produce rather illogical results (here is a paper that critiques someone about the reverse situation in which they included a variables level as a predictor of a differenced series.) If you rearrange the terms in the IV equation it actually looks similar to an augmented Dickey Fuller test.
While the simplest answer would be to ask the person who wrote the code, can anybody give an example in which this procedure would be acceptable, or any situation in which this procedure would return some meaningful results? As is I can not think of any logical reasoning why the differences would have an effect on the levels except in the case the series is non-stationary.
