There are some cards that have a ninjutsu ability, which means that you can target an unblocked creature and replace it with your creature (this can be done only after the declare blockers step).
Lets say that my opponents has an unblocked creature, and after I decide not to block it, he places a ninjutsu creature on the stack after paying its cost. Then, in response to that, I cast a lightning bolt to that creature (the one that is about to be replaced). When the lightning bolt resolves, the creature that dies and the ninjutsu creature has an illegal target.
My question is, should the ninjutsu creature go to the graveyard, or should it return to its owner hands?
Ninjutsu is defined as follows (as noted in this Wiki article):
702.48a Ninjutsu is an activated ability that functions only while the card with ninjutsu is in a player’s hand. “Ninjutsu [cost]” means “[Cost], Reveal this card from your hand, Return an unblocked attacking creature you control to its owner’s hand: Put this card onto the battlefield from your hand tapped and attacking.”
702.48b The card with ninjutsu remains revealed from the time the ability is announced until the ability leaves the stack.
702.48c A ninjutsu ability may be activated only while a creature on the battlefield is unblocked (see rule 509.1h). The creature with ninjutsu is put onto the battlefield unblocked. It will be attacking the same player or planeswalker as the creature that was returned to its owner’s hand.
An example of a ninjutsu creature: Ninja of the Deep Hours