In more formal grammatical frameworks, the construction you're describing is called an "it-cleft." The standard view is that it-clefts are licensed when the clefted constituent ("John" in "It was John who...") is a FOCUS. A FOCUS is a discourse function that expresses new, exhaustive, or contrastive information. In contrast, the it-cleft is not licensed or sounds odd if the clefted element is a TOPIC. A TOPIC is old information. To illustrate, consider the example below:
(1) a. Which student ate an apple?
b. It was [FOCUS John] who ate an apple.
(= John has not been mentioned in the question, new information, FOCUS, so it's acceptable)
(2) a. What did John do?
b. ??It was [TOPIC John] who ate an apple.
(= John has been mentioned in the question, old information, TOPIC, so this sounds odd)
There is much, much more to say about this, but this would be a good starting point.
Here is some literature on the topic.
Gundel, Jeanette K. 1974. The role of topic and comment in linguistic theory. Ph.D.
dissertation, University of Texas at Austin. Re-issued 1988, in Jorge Hankamer,
ed. Outstanding Dissertations in Linguistics, Garland Publishing Co.
Prince, Ellen F. 1978. 'A comparison of wh-clefts and it-clefts in discourse.' Language 54, 883-906.
Reinhart, Tanya. 1981. 'Pragmatics and linguistics. An analysis of sentence
topics.' Philosophica 27, 53-94.
Rizzi, L. 1997. 'The Fine Structure of the Left Periphery. In L. Haegeman (ed.), Elements of Grammar. Handbook in Generative Syntax. Dordrecht: Kluwer, 281-337.
Rooth, Mats. 1985. Association with Focus. PhD thesis. Amherst: University of
Massachusetts.