An example of when to say "what gives" is when your friend promised you the extra concert ticket but then decided at the last minute to give it to a different friend for no reason.
First attested in 1940. in John O'Hara's 1940 novel Pal Joey. The term is considered by the American Heritage Dictionary of Idioms, Second Edition (2013) and several other references to be a calque of German was gibt's? and/or a Yiddish equivalent. Brian Joseph considers this unlikely, however, and speculates that despite its extremely late attestation, it and the German was gibt's may "allow for a reconstruction of a Proto-West-Germanic existential use of 'give', which survives marginally into present usage."